MS Access 2016 vba: Empty value passed from form field (text box)

682 views Asked by At

I'm having a strange situation:

I have a simple form with 2 text boxes. The second one has the vba code triggered after being updated. For example: typing value to the first field, ENTER, typing value into the second field, ENTER and the code starts.

The code, initially, takes the values from the text boxes and assign them to the string variables (pre declared as strings), like:

test1 = Me.frmSSN.Value

The problem is, the test1 variable seems to be empty after the line above. It seems to happen only when I type, for example this string:

073QB8KJ2D00A4X

It works fine, when entering CNB0K2W5JK The tool is a simple serial number comparison.

Just for test, I've entered this line into the code:

aaa="073QB8KJ2D00A4X"

When running in the step-by-step mode and hovering mouse over the "aaa" I'm getting: aaa= and then nothing. Not even single "" like aaa="" or so. Just aaa=

After retrying multiple things - I believe it's about the value I enter:

073QB8KJ2D00A4X

Could be, that for access/vba it's some control string or so?

I'm just dumb now...

Thanks in advance for any help

Marek

p.s. Source fields are plain text boxes. And here's the code:

Dim user As String
Dim 1stSN As String
Dim 2ndSN As String
1stSN = Me.frmSSN.Value 2ndSN = Me.frmHPSN.Value

Then the values are being used as a part of SQL query. The problem is - in this situation - query doesn't work, as the sql string looks like:

"Select * From sbo_SerialSource where SN like " and nothing after "like". Debug shows the correct value (with serial number), but query fails with "syntax error" message. Seems like there are some strange "control characters" are being created/added.

That's it. And I have to use the serial numbers as these "strange ones", because that's how they come from the vendor.

0

There are 0 answers