Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Code Mixing + Access CMD Bttn

Status
Not open for further replies.

mooktion

Vendor
Apr 13, 2005
6
GB
Hey, this is probably a really easy question for some of you but as you will soon be able to tell, I am a complete rookie when it comes to VB.

Basically, I created a 'save record' button using the generator thing in Access. It generated the following on_click code:

Private Sub cmdProcessPayment_Click()
On Error GoTo Err_cmdProcessPayment_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_cmdProcessPayment_Click:
Exit Sub

Err_cmdProcessPayment_Click:
MsgBox Err.Description
Resume Exit_cmdProcessPayment_Click

End Sub

Now I want the following message box code to appear on the click event. I cn usually add this myself, but I am a little confused as it seems the on_click event has been coded already by the Access generated code. Anyway, the code I wanted to add is:

Private Sub Command8_Click()
Dim str As String
str = Forms![frmSubscriptions]![cboPlan]
MsgBox str

End Sub

Anyone can help me please?

PS, great forums :D
 
If you want to add it to the Save button you can do it like this. Add the Dim 'str as String' before the 'ON Error Goto...' Line and add the other two lines just before the 'DoCmd.DoMenuItem acFormBar...' line.

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
Awesome, perfect, and done :D! Thanks so much for your help!

PS. Damn, that was quick ;).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top