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

Compile Error: Expected: =

Status
Not open for further replies.

ProAdjuster

Technical User
Aug 31, 2007
12
I am trying to insert values into multiple columns within a related table through a button on my form. When I try to use this code, I get an error that says an "=" is expected.

Code:
Private Sub Command13_Click()
'Add Contact Status Log
    Insert
    INTO dbo_contactstatuslog(Contact, Status, Date)
[red]    VALUES (contacttempstore.contact,contact.status + 1,Now())[/red]
    
'Update Contact
    Update dbo_contact
    Set Status = [Status] + 1
    WHERE Contact = contacttempstore.Contact
End Sub
 
It looks like you are trying to run SQL code directly in vba. Try this (not tested, I don't know where contacttempstore stuff is coming from. Assumes it's another table):

Code:
Dim sSQL as String
sSQL = "INsert Into dbo_contactstatuslog(contact, status, date) SELECT contacttempstore.contact,contact.status + 1, Now() from contacttempstore"
DoCmd.RunSQL(sSQL)

Basically, you need to build the query in code then execute it.

Hope this helps,

Alex



[small]----signature below----[/small]
With all due respect, Don Bot, I don't think we should rely on an accident happening. Let's kill him ourselves.

Ignorance of certain subjects is a great part of wisdom
 
Contacttempstore is a table that I use to store the current contact so my lookup field will work. Access does not work very fast with the find feature. My form uses that field to requery to find a person by name.

In this code, I am using this table to record the current contact in the status log, and then to ensure that only the current contact's status is changed.


[small]Pardon my ignorace, but what does

Code:
[small]Dim sSQL as String
[COLOR=#cccccc]sSQL = "INsert Into dbo_contactstatuslog(contact, status, date) SELECT contacttempstore.contact, contact.status + 1, Now() from contacttempstore"[/color]
DoCmd.RunSQL(sSQL)[/small]

mean?[/small]
 
Ok, I figured out what that means... Contacttempstore has only one field... that is the contact number so that I can use it to reference the number later.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top