VBA - my downfall

aftershokk

Registered User.
Local time
Today, 18:50
Joined
Sep 5, 2001
Messages
259
I have a copy command button on a form as shown below (see VBA). I want to replace my "Message Box" note with an actual command to that will make sure this checkbox is 'null' after a copy of a record. Please help - thanks

Private Sub previous_record_button_Click()
On Error GoTo Err_previous_record_button_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
MsgBox "Remember to UNCHECK the sent Checkbox after the copy record command"

Exit_previous_record_button_Click:
Exit Sub

Err_previous_record_button_Click:
MsgBox Err.Description
Resume Exit_previous_record_button_Click

End Sub
 
ok first things first. that code you have is pretty obsolete. access wizards are pretty old!!

Code:
Private Sub previous_record_button_Click()
On Error GoTo Err_previous_record_button_Click

DoCmd.RunCommand acCmdSelectRecord
DoCmd.runcommand accmdcopy
DoCmd.RunCommand acCmdPasteAppend 
me.checkboxname= false

Exit_previous_record_button_Click:
Exit Sub

Err_previous_record_button_Click:
MsgBox Err.Description
Resume Exit_previous_record_button_Click

End Sub

should force the checkbox to return to its no value
 
reply

thanks

I am getting object required error?
 
Me. refers to the active object, typically the form that is open at the time.

So instead of writing out the entire form name to reference, in your case, the checkbox you can shorten it to Me.

Forms![MyFormName].Checkbox1 is equivalent to Me.Checkbox1
 
me refers to the active object i believe. its simpler than writing forms!activeformname.controlname
 
If you use a Function the same thing as be expressed:

Code:
Function AnyOldFunction()

With CodeContextObject

    .[MyControl].Visible = False

End With
End Function

The dot replaces the me in Sub Routines

Simon
 
Me. refers to the active object, typically the form that is open at the time.

So instead of writing out the entire form name to reference, in your case, the checkbox you can shorten it to Me.

Forms![MyFormName].Checkbox1 is equivalent to Me.Checkbox1

good explanation. haha :D:D:D
 

Users who are viewing this thread

Back
Top Bottom