#Name? Error on Form

Lkwdmntr

Registered User.
Local time
Today, 14:32
Joined
Jul 10, 2019
Messages
319
Hi Guys,

I added a new field "birthdate" to an existing table and form. When I go to add a new record using the form, the birthdate field fills in with "#Name?". I am stumped! Does anyone have any idea why this may be happening?
 
Last edited:
The Users table and the birthdate field from that table is the control source. On the form the field is txtBirthdate.
 
That doesn't really answer my question
I edited my answer. The source is the actual user's table, and the control source of the birthdate field is the birthdate from the table.
 
You need to add that field to the RecordSource of the form so it can be bound.
 
Can you post a sample db with test data to demonstrate the problem?
 
You need to add that field to the RecordSource of the form so it can be bound.
It is bound. In the properties section of the form, birthdate is used for the control source
Can you post a sample db with test data to demonstrate the problem?
I can. When you open the database. If you open the main menu and click "add user", you will see the problem. When you go to type in the first name, the birthdate field fills with #Name?. I have a meeting to go to now, so I will check back later this evening. Thanks for helping with this. It really stumped me.
 

Attachments

Looks to me like when you click Add User you launch your Users form to a new record for which some of the fields will be nulls because you just created a new empty record. Not sure why other fields don't do the same thing, but it might be format differences.

EDIT: I see that Arnel tried it and it didn't happen for him. I cranked up my anti-virus and tried it myself, and it didn't do that for me either.

So I was using Ac2010. What version of Access are you using? @arnelgp - what version of Access were you using when you did your test?
 
It is bound. In the properties section of the form, birthdate is used for the control source

I can. When you open the database. If you open the main menu and click "add user", you will see the problem. When you go to type in the first name, the birthdate field fills with #Name?. I have a meeting to go to now, so I will check back later this evening. Thanks for helping with this. It really stumped me.
Thanks for posting a sample DB. When I opened the Main Menu form and clicked Add New User, I tried to enter a First Name, but the #Name? error never showed up. Not when I was still entering a first name and also not when I tabbed out of it after I'm done.
1662421149062.png


Edit: Looks like I forgot to hit the "Post reply" button. Sorry for the delay and the duplicate info.
 
Thanks guys. I'm not sure what happened. I must have messed around with something to fix it. Wish I knew what it was. I am having trouble with field validation. I'm used to using code to make up rules with an after-insert event, but I thought I could use validation rules with validation text to warn the person entering data when something was wrong or missing. I put in some validation rules on the fields that have asterisks and are required. I tested it and nothing happened. It did nothing, it didn't even save the record. Any help would be appreciated.
 
Thanks guys. I'm not sure what happened. I must have messed around with something to fix it. Wish I knew what it was. I am having trouble with field validation. I'm used to using code to make up rules with an after-insert event, but I thought I could use validation rules with validation text to warn the person entering data when something was wrong or missing. I put in some validation rules on the fields that have asterisks and are required. I tested it and nothing happened. It did nothing, it didn't even save the record. Any help would be appreciated.
I prefer doing data entry validation using the Form's BeforeUpdate event.
 
For Validation Date, You can use it.
Code:
<=Now()
User can't enter future a date.
Code:
>=Now()
User can't enter Past a date.
I put in some validation rules on the fields that have asterisks and are required. I tested it and nothing happened.
I using for validation Field this Function
Code:
Private Function ValidateRecord() As Boolean
Dim strVR As String
    strVR = ""   
    'Validate the form
    If IsNothing(Me![EmployeeName]) Then strVR = "You must enter Employee Name" & vbCrLf
    If IsNothing(Me![cboStatus]) Then strVR= strVR & "You must select a Employment Status" & vbCrLf
    If Not IsDate(Me![EmploymentDate]) Then strVR = strVR & "You must enter the Date Employment Started" & vbCrLf
    
    If Len(strVR ) <> 0 Then
        MsgBox "The following entry errors have found" & vbCrLf & strVR , vbCritical + vbYesNo, "Invalid Entry"
        ValidateRecord = False
    Else
        ValidateRecord = True
    End If
HandleExit:
    Exit Function
End Function

Then its called in your SAVE or UPDATE button

Code:
Private Sub cmdSave_Click()

    If (IsNull(ValidateRecord)) Then
       Form.SetFocus
    End If
    If ValidateRecord <> 0 Then
       MsgBox "The entered data has been saved successfully" & vbCrLf & _
        "" & vbCrLf & _
        "You can choose others tab", vbInformation + vbOKOnly, "Saved Successful"
        DoCmd.GoToRecord , "", acNewRec
        'DoCmd.RunCommand acCmdSaveRecord
    End If
End Sub
 
This information is great and much appreciated, but I was wanting to know why the validation rules and validation text weren't working and if one of the fields were empty, it didn't even save the record. Why would that happen?
 
This information is great and much appreciated, but I was wanting to know why the validation rules and validation text weren't working and if one of the fields were empty, it didn't even save the record. Why would that happen?
Do you have another sample db showing this problem?
 

Users who are viewing this thread

Back
Top Bottom