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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Me.AllowEdits not working from public module

Status
Not open for further replies.

JOD59

Technical User
Dec 17, 2003
39
US
Hi all, I'm just a newbe so forgive my ignorance. Does anyone know how I would code this to use in a public module (works fine in privet call)? I keep getting an error that I have misused a keyword when I use it in the public call.


Public Sub Cmd_Edit()
Dim iResponse As Integer
iResponse = MsgBox("Do you want to Edit Record ?", vbYesNo)
If iResponse = vbYes Then
Me.AllowEdits = Not Me.AllowEdits
End If


End Sub
 
The Me. reference is usually to the current form and, if you place this in a module, there is no current form ... hence the error. You probably need to do something like
Code:
Public Sub Cmd_Edit(
frm As Form
Code:
)
Dim iResponse As Integer
iResponse = MsgBox("Do you want to Edit Record ?", vbYesNo)
If iResponse = vbYes Then
frm
Code:
.AllowEdits = Not
frm
Code:
.AllowEdits
End If
And you call it with
Code:
   Cmd_Edit Me

BTW: This code is just toggling the "AllowEdits" property so if you started with that value as TRUE, then the call to this function would ask "Do you want to Edit Record ?" and if the user clicked "Yes" then it would be set to "FALSE" and the user would NOT be able to edit records even though he said that he wanted to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top