1

I have a textbox(in form) and a field(in table) both named SerialNumber

This is the control source of the textbox: =([OrderNr] & (""+[Aantal]) & "" & [SapArtNr])

I can't seem to make the textbox save the value inside into the table.

Edit:

Option Compare Database

Private Sub Command82_Click()
    ' Add data to Table
    CurrentDb.Execute "INSERT INTO Geleidelijst(SerialNmbr, InvoerOrderNr, InvoerAantal, InvoerVermogen, InvoerHSLSSpn) " & _
            " VALUES(" & Me.SerialNumberLong & ",'" & Me.OrderNr & "','" & _
            Me.Aantal & "','" & Me.Vermogen & "','" & Me.HSLSSpn & "')"
End Sub

But then I get error: 3075 Synax error missing operating in query expression. And if I add date as a format it doesn't work either.

Only when it's numbers, but when there's letters and dots and "/" for example, it won't work.

Any help would be nice, thanks.

4
  • What has this to do with sql? Commented Jul 27, 2022 at 11:56
  • 1
    You assign the expression to a read-only textbox as its ControlSource. That won't update a table field. Commented Jul 27, 2022 at 20:39
  • @Gustav Yeah thanks, I've tried different methods but still no success, updated the post. Commented Jul 28, 2022 at 6:09
  • @jens Nothing. was an accident Commented Jul 28, 2022 at 6:10

1 Answer 1

1

Most likely, Aantal is numeric, so try without quotes:

CurrentDb.Execute "INSERT INTO Geleidelijst " & _
    "(SerialNmbr, InvoerOrderNr, InvoerAantal, InvoerVermogen, InvoerHSLSSpn) " & _
    "VALUES('" & Me.SerialNumberLong & "','" & Me.OrderNr & "'," & Me.Aantal & ",'" & Me.Vermogen & "','" & Me.HSLSSpn & "')"
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer, I could also try this with one textbox (SerialNumberLong), which is the important one. It conaints this value in the textbox: "23423423Q1000NB309 21/0.4 5I" But even with the code you sent I still get the error: "3075 Synax error missing operating in query expression
That serial no. is text. See edited answer, please.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.