Click button event doesn't run code

aman

Registered User.
Local time
Today, 14:54
Joined
Oct 16, 2008
Messages
1,251
Hi guys

In the Main Form , I have few buttons and I am writing the following code to open the right form when a button is clicked but unfortunately the code isn't doing anything. No form is opening. I am using MS office 2010. ANy help would be much appreciated.

Code:
Private Sub BtnOption_Click()
DoCmd.OpenForm "Form1", acNormal, , , acFormAdd, acDialog
End Sub
 
Private Sub Form_Load()
'Me!Label1.Caption = "Welcome " & Environ("username") & "!"
Me!Label1.Caption = "Welcome "
End Sub
 
Private Sub Option1_Click()
DoCmd.OpenForm "Form1", acNormal, , , acFormAdd, acDialog
End Sub
 
Private Sub Option2_Click()
DoCmd.OpenForm "Form5", acNormal, , , acFormAdd, acDialog
 
End Sub
 
Private Sub Option3_Click()
DoCmd.OpenForm "Form6", acNormal, , , acFormAdd, acDialog
 
End Sub
 
Private Sub Option4_Click()
DoCmd.OpenForm "Form8", acNormal, , , acFormAdd, acDialog
 
End Sub
 
if you wish to open a form
Just use Form Design-View--->Control Box--->create command button

If you cannot see, then goto View-->Toolbar--->control box

Just simple, ACC2003/2010 ask you thru wizard for which form to open

If u insist on VBA, then try "VBA Form Open Add" on AWF
 
right-click on created button thru Microsoft wizard mode
goto Event tab--->Onclick -- on rightmost side of [event procedure] text
click [...] button
you will be taken to vba script!
 
Sumox , this is what I am doing. I am writing code in VBA but it doesn't open up a form when I click on the button. Not sure whats going wrong really...
 
Aman, I have come accross this many times. Simply cut your code and remake the events by double clicking on the onclick event in form design.

After recreating paste your code back into them.

Regards,
BlueIshDan :)
 
just open up a form when a button is clicked. The same code works fine for access 2003 but not sure why 2010 is giving me the problem??
 
just open up a form when a button is clicked. The same code works fine for access 2003 but not sure why 2010 is giving me the problem??

Aman, I have come accross this many times. Simply cut your code and remake the events by double clicking on the onclick event in form design.

After recreating paste your code back into them.

Regards,
BlueIshDan
 
I have done that too but still it doesn't work... :((
 
tried this ?
Private Sub lstBookData_DblClick(Cancel As Integer)
DoCmd.OpenForm "FrmBookInfo", acNormal, , , , , lstBookData.Column(0, lstBookData.ListIndex + 1)
End Sub
 
forget the control/field name in vba and you missed 1 comma i think
 
I tried it and it works in another access database. But why its not working in my current database that i moved from Access 2003 to 2010???
 
ahhh i just noticed the file extension in the databse i just created in .accdb but the one i copied from 2003 to 2010, its file extension is .mdb.

Do i need to convert that into .ccdb? if yes then how can I do that? Thanks
 
I find microsoft development environments can get scambled. Try renaming the form in the project that it works in and then copy the renamed form into the one that it doesnt work in. This might make the project try to rebuild it.
 

Users who are viewing this thread

Back
Top Bottom