How to keep a variable alive? (1 Viewer)

wavemehello

New member
Local time
Today, 04:37
Joined
Feb 13, 2006
Messages
5
Hi all,
I have a simple access form. It has a simple command button. When I click the command button, the form will be closed(i have used docmd.close) and another form opens(docmd.openform) with a command button in that and the current form becomes closed. When the command button is again clicked, that form also closes and a new form opens with another command button. All I need to do is I need to trace the total count of the command buttons clicked which later should go in a record of a certain table.
Help please
 

Ron_dK

Cool bop aficionado
Local time
Today, 13:37
Joined
Sep 5, 2002
Messages
2,141
I don't see the reason of counting the number of forms opened or closed.
Normally, one would track the addition/mutation of records entry in the Dbase.
If that's what you want search this forum for audit trail.
 

wavemehello

New member
Local time
Today, 04:37
Joined
Feb 13, 2006
Messages
5
Counting no. of clicks

Actually, each button is, the correct option of a quiz question based on which I want to calculate this final score. Also his name and score should go to the table record.
 

Oldsoftboss

AWF VIP
Local time
Today, 21:37
Joined
Oct 28, 2001
Messages
2,499
Declare the variable as public in a module.

Public varName as long (or whatever)

Dave
 

wavemehello

New member
Local time
Today, 04:37
Joined
Feb 13, 2006
Messages
5
Let me explain!

I have a form formA. In the general declaration of the form I have written Public total as integer. This formA has just 1 command button at all which when I click FormA closes (docmd.close) and another form formB opens (docmd.open) this formB also has only 1 command button and nothing else. When I click the command button of formB again FormC should open. This way I have made 30 forms for quiz contest program. All I need is, the total variable should be available to all forms with 1 increment when the command button is clicked everytime.
 

Ethereal

Warcraft III Player
Local time
Today, 07:37
Joined
Jan 17, 2006
Messages
99
hit refresh on ur browser and read above comment by old softboss :p
 

wavemehello

New member
Local time
Today, 04:37
Joined
Feb 13, 2006
Messages
5
ok I did it

I added a module and declared a public variable called total and now I can access the var from any form. I have been able to capture the value of the variable. Now How can I replace the value of this variable to a field called (score) in xyz table. In dbase I used to do it with the command 'replace score with total'. I am new to Access and vb! So please write the command but I guess, its not more than 1 or 2 lines! Waiting..




The truth is that there are novice learners of VB who need Mercy!
 

Oldsoftboss

AWF VIP
Local time
Today, 21:37
Joined
Oct 28, 2001
Messages
2,499
How do you want to get the score to the table? By pressing a button on a Results Form?, or be automatically displayed when a form opens? or automatically after the last question is answered?

I would do this a bit different. Rather than having 30 forms, just have one form with a tab control with 30 tabs. Set the tab style to none. (I do this with code in the load event so it easier to design). Bind the form to the contestant/ student and have a hidden field that holds the value. On each tab simply put a button that says "Next Question". In the On Click event of each button simply set the focus to the next button and put Me.txtResult = Me.txtResult + score from that tab.

Dave
 

Oldsoftboss

AWF VIP
Local time
Today, 21:37
Joined
Oct 28, 2001
Messages
2,499
A bit like this.....
 

Attachments

  • db1.zip
    14.8 KB · Views: 122

wavemehello

New member
Local time
Today, 04:37
Joined
Feb 13, 2006
Messages
5
Thankx for the code but

Yes, I have tried and created those 30 forms having different pictures and some enhancements also using mydb.openrecordset.. and defining some varibles, I am now able to transfer the scores in a table. But now the big challenge in front of me is I do not know how to make that database and the table share in a network environment so that when 10 users run the quiz, their scores should go and get entered in the same table instead of running it separately in 10 computers. This is out of my knowledge. It would be a great favour to me! Please...
 

Users who are viewing this thread

Top Bottom