I'm having trouble getting the value of a TextBox in VBA code. Either I'm stupid or Access is utterly ridiculous.
Ultimately, I'm trying to open a form using a where clause which is built based on the current value of a TextBox. The TextBox which has the string I want has a ControlSource set and it changes automatically based on which record is currently selected on the containing form.
Code:
DoCmd.OpenForm FormName:="JobDetails", WhereCondition:="JobRef = '" & JobID.Value & "'"
I've narrowed the problem down to the fact that the current value of the text box is (apparently) not accessible at run-time. Here is an example (name of TextBox is JobID):
Code:
MsgBox Me.JobID.Value
The string returned by JobID.Value is a string of 8 question marks "????????". I also tried:
Code:
MsgBox Me.JobID.Text
That was an error because JobID didn't currently have focus. This is cheesy because why does it EFFING matter what has focus? Then I tried:
That also returns 8 question marks.