Error code 3075

Jamster45

New member
Local time
Today, 10:45
Joined
Aug 15, 2018
Messages
7
Hi There,

I got an error on this code:


Code:
Public Sub logging(Activity As String, filterQ As String)
    CurrentDb.Execute "INSERT INTO activiteitenlog (gebruikersnaam,activiteit,stringq,windowsGebruikersnaam,windowsComputernaam) Values('" & TempVars("gebruikersnaam").Value & "', '" & Activity & "', '" & filterQ & "', '" & Environ("username") & "','" & Environ("computername") & "')"
End Sub

I placed this on a form:

Private Sub Form_Load()
globals.logging "form opened", Me.filter
End Sub

I got the error: 3075, syntax is missing (operator)

The error is in the me.filter/filterQ section because, whitout it works fine


can someone help me and explain what im doing wrong here?
 
Last edited by a moderator:
Suggest you post a copy of the database if possible.

No idea what this means/represents
me.filter/filterQ
 
What is contained in the filter when it happens? Try this:

http://www.baldyweb.com/ImmediateWindow.htm

like

Debug.Print filterQ

and you could use a string variable for the whole SQL string and print it too.
 
I commonly recommend you use a QueryDef, and this is no exception. It's more verbose in code terms, but simpler to understand the SQL, easier to see where each parameter value is being assigned, and delimiters are not your problem.
Consider code like...
Code:
Public Sub logging(Activity As String, filterQ As String)
    Const SQL_INSERT As String = _
        "INSERT INTO activiteitenlog " & _
            "( gebruikersnaam, activiteit, stringq, windowsGebruike, windowsComputernaam ) " & _
        "VALUES " & _
            "( p0, p1, p2, p3, p4 ) "
            
    With CurrentDb.CreateQueryDef("", SQL_INSERT)
        .Parameters(0) = TempVars("gebruikersnaam")
        .Parameters(1) = Activity
        .Parameters(2) = filterQ
        .Parameters(3) = Environ("username")
        .Parameters(4) = Environ("computername")
        .Execute dbFailOnError
        .Close
    End With

End Sub
Just my 2c...
Mark
 
I don't know if it is a typo, but there is a space:
CurrentDb.Execute "INSERT INTO activiteitenlog (gebruikersnaam,activiteit,stringq,windowsGebruike rsnaam,windowsComputernaam) " _
 
I don't know if it is a typo, but there is a space:

There is no space, the forum adds one if there are too many characters in a row with no space. I added code tags to the OP's post, which will preserve the actual text.
 
There is no space, the forum adds one if there are too many characters in a row with no space. I added code tags to the OP's post, which will preserve the actual text.
Okay - did you edit something in OP post or was adding code tags enough for the space to disappear?
How many characters are to many?
 
All I did was add code tags; there was no space in the text. If memory serves, it's around 50. I'll test:

12345678901234567890123456789012345678901234567890123456789012345678901234567890

Edit: Looks like 60. There are no spaces in the numbers above.

Edit 2: it moved to 50!
 
The SQL string doesn't have a closing semi-colon, which would make the SQL processor think that something else must be coming after your Environ("Computername") element. That something would normally be either the closing ";" or a delimiter for another argument or an operator for you to modify the last argument. I guess it picked "operator" to complain about even though you have a closing parenthesis after the last element of the VALUES clause.

It is either that or the "Activity" or "FilterQ" argument that were your inputs contained some form of punctuation that messed with the quote count. Remember that your string gets processed TWICE. Once by the VBA code as it is building that string. Once by the SQL query processor. Even if the string can be built by VBA, that doesn't mean that SQL is going to like it. (Which I'm guessing it does not.)
 
I believe the semicolon is optional in Access Doc. I never include one when building SQL in VBA.
 
Paul, I used to think it was, too, but I've tripped over it a few times. Admittedly rare, and being the yutz that I sometimes can be, I NEVER remember to take notes when it happens because I'm so focused on getting the darned thing running.
 

Users who are viewing this thread

Back
Top Bottom