Base Question

johann201

Registered User.
Local time
Today, 12:02
Joined
Dec 14, 2006
Messages
39
Hi people...:)

I create a form with 2 buttoms
The first running in VBA and the second In MACRo

Why the MACRO buttom don't work?

Thanx in ADVANCE...

Johann
 
Sorry, you didn't provide enough information. What is each button supposed to be doing, what steps are you trying to do with the macro, etc.?

Without that, and possibly even more information, we can only tell you that it didn't work because your macro is incorrect or incorrectly assigned to the button.
 
Thanx bob for fast reply

The first btm is cancel in vba:
Dim booFormLock As Boolean

Private Sub cmdCancel_Click()
Me.Undo
booFormLock = True
DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_Load()
' default the form to a new record each time
DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Not booFormLock Then Cancel = True
End Sub


and the second is OK base in macro which:

1.save the new record of the form
2.close the form
3.open another form

Oh!I don't know vb...the cancel btm i found it on the forum...
 
You can use this as the basis for your macro button (instead of the macro):
Code:
DoCmd.RunCommand acCmdSaveRecord 'saves the record
DoCmd.Close acForm, Me.Name, acSaveNo 'closes the current form
DoCmd.OpenForm "PutYourFormNameYouWantToOpenHere", acNormal 'opens the other form

Where it says "PutYourFormNameYouWantToOpenHere" replace those words with the actual name of the form you want to open. Remember to keep it within the quotation marks (the quotation marks must be included).

Where it says Me.Name don't change it, that code tells it, within the context of the closing of the form to close the form with the name of the current form that this code is on. Me. is a programming shortcut that lets you not have to fully type out the form reference if the code is on the same form as you are referring to.

I hope that helps.
 

Users who are viewing this thread

Back
Top Bottom