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

Run-Time error 424 object required

Status
Not open for further replies.

MSVBA

Technical User
Jun 1, 2010
2
US
when I click on the button, SQL update runs fine. but when it gets to insert query - it is displaying Run Time Error 424 object required.
Immediate window shows insert SQL query - if I run the query itself, it runs fine. I am totally stuck!!!!

Private Sub Command32_Click()


Dim intEntityID As Long
Dim intuserid As Long
Dim intcontactid As Long
Dim intpersonid As Long
Dim strFY11Access As String
Dim strType As String

intEntityID = [Forms]![frmEntityUsers].[EntityID]
intuserid = [Forms]![frmEntityUsers].[UserID]
intcontactid = [Forms]![frmEntityUsers].[ContactID]
intpersonid = [Forms]![frmEntityUsers].[PersonID]

Dim strupdateAccess As String
Dim strQuery As String
strFY11Access = [Forms]![frmEntityUsers].[FY11GMEAccess]
If Len(strFY11Access) > 0 Then
strFY11Access = [Forms]![frmEntityUsers].[FY11GMEAccess]
Else
strFY11Access = "No LEA Access"
End If

Debug.Print strFY11Access



strupdateAccess = "Update tblUsers Set FY11GMEAccess = '" & strFY11Access & "' where userid = " & intuserid & ";"
Debug.Print strupdateAccess

DoCmd.RunSQL strupdateAccess

Dim strGME As String
If strFY11Access = "GSA Signer" Then
strGME = "LS"
ElseIf strFY11Access = "LEA Capture Only" Then
strGME = "LC"
ElseIf strFY11Access = "County GSA Signer" Then
strGME = "CS"
Else
strGME = "No LEA Access"
End If
Debug.Print strGME
If strGME <> "No LEA Access" Then

strQuery = "Insert into dbo_GMEcEntityUsers Select 2011, EntityID,UserID, ContactID, PersonID, '" & strGME & "' from TempEntityUsers where userid = " & intuserid & ";"

Debug.Print strQuery

DoComd.RunSQL strQuery
Else
End If



End Sub

 
Replace this:
DoComd.RunSQL strQuery
with this:
DoCmd.RunSQL strQuery

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 


Hi,
Code:
Debug.Print strQuery
Please post the SQL from your Immediate Window.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
PHV - thanks -
I feel so stupid. I had this error since last Friday - I got so frustrated.
You are right - after changing the following code, everything works -- thanks

DoCmd.RunSQL strQuery
 
Tip: use the Option Explicit instruction.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top