help with insert into statement

mikeco555

Registered User.
Local time
Today, 14:10
Joined
Jan 23, 2004
Messages
22
hi,
I am trying to insert a few values into my companies database using an insert into statement. Everything goes well untill I try to insert a value into a field name called # Refills, no matter what syntax I use it will not allow me to insert the value into the field .... Is it something to do with the "#" character????

anyway here is the code....Please help!!!



Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim strSqlmedInsert As String
If Action.VALUE = "A" Then

strSqlmedInsert = "INSERT INTO medications ( medication, quantity, frequency, #_refills)"

strSqlmedInsert = strSqlmedInsert & "Select '" & strMedName & "' , '" & strQuantity & "' , '" & strPatInstructions & "' , '" & strRefills & "' "

cnn.Execute strSqlmedInsert, , adExecuteNoRecords
 
Mike,

Don't really like the "#" in the field name ...

Code:
DoCmd.RunSQL "INSERT INTO medications (medication, quantity, frequency, #_refills) " & _
             "Values('" & strMedName & "' , '" & _
                          strQuantity & "' , '" & 
                          strPatInstructions & "' , '" & 
                          strRefills & "');"

Wayne
 
Try putting brackets around it. [#_refills]
 

Users who are viewing this thread

Back
Top Bottom