Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Missing Operator (A2k)

    With the following, I'm getting missing operator (VehicleCheck), I can't see where, can anyone else see the problem:

    <pre>Dim VehicleCheck As Integer
    Dim strWhere As String
    ' Check for duplicates
    strWhere = "Manufacturer = Forms!frmVehicleAdmin!Manufacturer And
    Model = Forms!frmVehicleAdmin!Model and
    Derivitive = Forms!frmVehicleAdmin!Derivitive"</pre>


    <pre>VehicleCheck = DCount("*", "tblParts", "Manufacturer=" & Chr(34) & _
    Me!Manufacturer & Chr(34) & "Model=" & Chr(34) & _
    Me!Model & Chr(34) & "Derivitive=" & Chr(34) & _
    Me!Derivitive & Chr(34) & strWhere)</pre>


    <pre>If VehicleCheck > 0 Then
    MsgBox "Test "
    Exit Sub
    End If</pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Missing Operator (A2k)

    You forgot And between the conditions, and it seems to me that you are duplicating the conditions by enumerating them explicitly AND appending them as strWhere:<pre>VehicleCheck = DCount("*", "tblParts", "Manufacturer=" & Chr(34) & _
    Me!Manufacturer & Chr(34) & " And Model=" & Chr(34) & _
    Me!Model & Chr(34) & " And Derivitive=" & Chr(34) & _
    Me!Derivitive & Chr(34)<font color=red> & strWhere</font color=red>)</pre>


  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Missing Operator (A2k)

    Thanks Hans
    I must have been staring at it too long !!
    Removing the strWhere seems to work fine.

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Missing Operator (A2k)

    <P ID="edit" class=small>(Edited by D Willett on 01-Nov-03 14:14. Calmed down now)</P>strSQL = "INSERT INTO tblVehicles (Manufacturer, Model, subModel) "
    VALUES (" & Chr(34) & Forms!frmVehicleAdmin!Manufacturer & Chr(34) & ", " &
    Chr (34) & Forms!frmVehicleAdmin!Model & Chr(34) & "," & Chr(34) &
    Forms!frmVehicleAdmin!Derivitive & Chr(34) & ""

    <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

    Excuse me for getting my hair off, The insert into statement is causing me to be a little unstable:

    <pre>Dim VehicleCheck As Integer
    Dim strNewModel As String
    Dim strSQL As String

    strNewModel = "Manufacturer = Forms!frmVehicleAdmin!Manufacturer And Model
    = Forms!frmVehicleAdmin!Model and Derivitive = Forms!frmVehicleAdmin!Derivitive"


    strSQL = "INSERT INTO tblVehicles (Manufacturer, Model, subModel) "
    VALUES (" & Chr(34) & Forms!frmVehicleAdmin!Manufacturer & Chr(34) & ", " &
    Chr (34) & Forms!frmVehicleAdmin!Model & Chr(34) & "," & Chr(34) &
    Forms!frmVehicleAdmin!Derivitive & Chr(34) & ""

    ' Check for duplicates
    VehicleCheck = DCount("*", "tblVehicles", "Manufacturer=" & Chr(34) & _
    Me!Manufacturer & Chr(34) & " And Model=" & Chr(34) & _
    Me!Model & Chr(34) & " And Derivitive=" & Chr(34) & Me!Derivitive & Chr(34))

    If VehicleCheck = 0 Then
    MsgBox strNewModel
    DoCmd.RunSQL strSQL

    ElseIf VehicleCheck > 0 Then
    MsgBox "Vehicle Exists"
    Exit Sub
    End If
    End Sub</pre>


  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Missing Operator (A2k)

    You forgot a concatenation &, several continuation characters _ and the closing bracket:<pre>strSQL = "INSERT INTO tblVehicles (Manufacturer, Model, subModel) " & _
    "VALUES (" & Chr(34) & Forms!frmVehicleAdmin!Manufacturer & Chr(34) & ", " & _
    Chr(34) & Forms!frmVehicleAdmin!Model & Chr(34) & "," & Chr(34) & _
    Forms!frmVehicleAdmin!Derivitive & Chr(34) & ")"</pre>


  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Missing Operator (A2k)

    Thanks again.

    I think I'm just having a bad day.
    I better leave it alone now.
    The strSQL is fine now.

    Have a good weekend.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •