The error message is saying, in essence, that it cannot find a Control/Field named txtLeadDivision. If there is, in fact, one with that name, your Control named txtLeadDivision may be corrupt, or the Form, or the Database, itself. Importing everything into a new. blank file will resolve the latter two cases, but I'm not sure about the first case, where the Control is corrupt.
If RG's advice doesn't work, you might Delete the txtLeadDivision Control and then re-create it.
This has nothing to do with your problem (unless the txtLeadDivision Control doesn't exist) but when you have a large number of Ifs in an If...Then construct, or a lot of tests, like you do here
Code:
If Me.txtLeadDivision = "Corporate" Or Me.txtLeadDivision = "Trust-wide" Or Me.txtLeadDivision = "Primary Care" Or Me.txtLeadDivision = "1" Or Me.txtLeadDivision = "2" Or Me.txtLeadDivision = "3" Or Me.txtLeadDivision = "4" Or Me.txtLeadDivision = "5" Or Me.txtLeadDivision = "A" Or Me.txtLeadDivision = "B" Or Me.txtLeadDivision = "C" Or Me.txtLeadDivision = "D" Then
Me.txtNewProjectID = ("CA" & Me.txtLeadDivision & "-" & Format(Me.txtArbitraryNumber, "00000") & "-" & Right(Me.txtFirstEntered, 2))
Else
Me.txtNewProjectID = ("CA" & "0-" & Format(Me.txtArbitraryNumber, "00000") & "-" & Right(Me.txtFirstEntered, 2))
End If
it's probably better to use a Select Case construct:
Code:
Select Case txtLeadDivision
Case "Corporate", "Trust-wide", "Primary Care", "1", "2", "3", "4", "5", "A", "B", "C", "D"
Me.txtNewProjectID = ("CA" & Me.txtLeadDivision & "-" & Format(Me.txtArbitraryNumber, "00000") & "-" & Right(Me.txtFirstEntered, 2))
Case Else
Me.txtNewProjectID = ("CA" & "0-" & Format(Me.txtArbitraryNumber, "00000") & "-" & Right(Me.txtFirstEntered, 2))
End Select
It's shorter/cleaner and much easier to read, as you'll see if you copy and paste it into the Form's code window.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007