A family of Microsoft relational database management systems designed for ease of use.
Starting a field name with a number is the problem.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have the following code in my Form Open section. It all works except one line in the middle. The line starting Me.cbo30CFRID.Value It has an error "Run-time error '3075': Syntax error (missing operator) in query expression '30CFRID'."
I cannot find where it's any different than the lines above or below. Other than it referencing 30CFRID of course. What am I missing?
The table, tblCitations, has a 30CFRID field. Again, everything else works. If I step past that line, the rest of it fires off, the form opens, and it's populated except the 30CFR line.
EDIT: So, I fixed it by adding [ ] so it's now "[30CFRID]". But could someone still explain WHY it needed brackets when the others didn't? Should I be adding the brackets to everything just in case?
If sMode = "Edit" Then
lCitationID = Me.OpenArgs
Me.txtCitationID.Value = lCitationID
Me.txtCitationNumber.Value = DLookup("CitationNumber", "tblCitations", "CitationID = " & lCitationID)
Me.cboShiftID.Value = DLookup("ShiftID", "tblCitations", "CitationID = " & lCitationID)
Me.cboEmployeeID.Value = DLookup("EmployeeID", "tblCitations", "CitationID = " & lCitationID)
Me.txtCitationDate.Value = DLookup("CitationDate", "tblCitations", "CitationID = " & lCitationID)
Me.cboCategoryID.Value = DLookup("CategoryID", "tblCitations", "CitationID = " & lCitationID)
Me.cbo30CFRID.Value = DLookup("30CFRID", "tblCitations", "CitationID = " & lCitationID)
Me.cboSSOID.Value = DLookup("SSOID", "tblCitations", "CitationID = " & lCitationID)
Me.txtCondition.Value = DLookup("Condition", "tblCitations", "CitationID = " & lCitationID)
Me.txtEstimatedAssessment.Value = DLookup("EstimatedAssessment", "tblCitations", "CitationID = " & lCitationID)
Me.cboLocationID.Value = DLookup("LocationID", "tblCitations", "CitationID = " & lCitationID)
Me.cboUnitID.Value = DLookup("UnitID", "tblCitations", "CitationID = " & lCitationID)
End If
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Starting a field name with a number is the problem.
Answer accepted by question author
Does it help if you use
Me.cbo30CFRID.Value = DLookup("[30CFRID]", "tblCitations", "CitationID = " & lCitationID)
Thank you very much.
Yes, I edited my question after testing that. With the brackets it does work. So that's good. But could you explain why that line needs brackets? Is it just because there are numbers in the name? Should I be using brackets all the time, or just worry about it when it doesn't work without the brackets?