SQL Help

businesshippieRH

Registered User.
Local time
Yesterday, 20:46
Joined
Aug 8, 2014
Messages
60
I've looked over this bit of code so many times and have no idea what I'm missing... here's hoping a fresh pair of eyes'll catch it!

Code:
'BEFORE THIS IS A BUNCH OF STUFF TO MAKE SURE NONE OF THE VARIBLES ARE NULL
'Save Record to tbl_EquipmentList
'Set Up Strings
    Dim ID As Variant
        ID = Me.txt_TrinityID
    Dim Rental As Variant
        Rental = 0
    Dim Name As String
        Name = Me.txt_EquipmentName
    Dim TypeID As Variant
        TypeID = Me.cmb_EqType
    Dim MF As String
        MF = Me.txt_Manufacturer
    Dim MNo As String
        MNo = Me.txt_ModelNo
    Dim SN As Variant
        SN = Me.txt_SerialNo
    Dim Func As Variant
        Func = -1
    Dim Cost As Currency
        Cost = Me.txt_CostToReplace
Dim SaveSQL As String
SaveSQL = "INSERT INTO tbl_EquipmentList " & _
"(TrinityID, Rental, EquipmentName, EqTypeID, Manufacturer, ModelNo, SerialNo, Functional, CostToReplace) " & _
"VALUES (" & ID & ", " & Rental & ", " & Name & ", " & TypeID & ", " & MF & ", " & MNo & ", " & SN & ", " & Func & ", " & Cost & ")"
Debug.Print SaveSQL
'Run SQL
DoCmd.RunSQL SaveSQL

And Debug Print out:
Code:
INSERT INTO tbl_EquipmentList (TrinityID, Rental, EquipmentName, EqTypeID, Manufacturer, ModelNo, SerialNo, Functional, CostToReplace) VALUES (1111, 0, Domafledgee, 42, Acme, EXTREME1000, 123abc, -1, 1000000)

For some reason, it's throwing a syntax error on the MF variable. Thanks in advance!
 
Duh... Thanks! This is what happens when you spend more time counting the spaces and commas than stepping back and looking at the whole thing.
 
No problem. Been there, done that. :p
 

Users who are viewing this thread

Back
Top Bottom