Compile Error Method or Data Member not found (1 Viewer)

cyd44

Registered User.
Local time
Today, 16:59
Joined
Oct 30, 2011
Messages
85
Could anyone please help on the above error. I am trying to update a table using VBA aand am using the following code
Code:
strSQL = " UPDATE [patient]" & _
         " SET [Current_Med] = '" & Me.MyMed & "'," & _
         " [SType1] = '" & Me.SType_1 & "'," & _
         " [SType2] = '" & Me.SType2 & "'," & _
         " [SType3] = '" & Me.Stype3 & "'," & _
         " [SClass1] = '" & Me.SClass1 & "'," & _
         " [SClass2] = '" & Me.SClass2 & "'," & _
         " [SClass3] = '" & Me.SClass3 & "'" & _
         " WHERE ([UID] = '" & Me.Web_UID & "')"
Call DoCmd.RunSQL(strSQL)
When I run the code I get the compile error which points to Me.Type3

Strangely however if I use this code
Code:
strSQL = " UPDATE [patient]" & _
         " SET [Medication] = '" & Me.MyMed & "'," & _
         " [SType_1] = '" & Me.SType_1 & "'," & _
         " [SType2] = '" & Me.SType2 & "'," & _
         " [SType3] = '" & Me.Stype3 & "'" & _
         " WHERE ([Web_UID] = '" & Me.Web_UID & "')"
Call DoCmd.RunSQL(strSQL)

The code compiles and runs ok.

I needed to add the SClass variables to the update statement shown above and this is when the compile error surfaced.

I can recognise that the problem is around the SType3 area but I cant see the wood for the trees. Can anyone suggest what is wrong?
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Today, 11:59
Joined
Jan 23, 2006
Messages
15,394
In one case you have UID, in another it's Web_UID???

Put debug.print strSQL as a new line between the "WHERE... line and the Call.
Comment the Call line for the moment.
Then
Look in the immediate window (Cntl G) and see what was printed; copy it and post it.

Also, check your table, and your form to ensure the spelling of the field names.
 

cyd44

Registered User.
Local time
Today, 16:59
Joined
Oct 30, 2011
Messages
85
In one case you have UID, in another it's Web_UID???

Put debug.print strSQL as a new line between the "WHERE... line and the Call.
Comment the Call line for the moment.
Then
Look in the immediate window (Cntl G) and see what was printed; copy it and post it.

Also, check your table, and your form to ensure the spelling of the field names.

Thanks for response. I found the problem. I had cut and pasted wrong coding
 

Users who are viewing this thread

Top Bottom