seangefferson
Technical User
- Aug 18, 2010
- 2
Hello:
I'm totally new to Access and so my question may be so basic it's embarassing but here goes.
I have created a form with 4 fields on it:
fname
mname
lname
display_name
I want the user to enter the customer name in the first 3 fields and then have a command button to fill the display_name field with the first three fields concatenated. But, if the middle name (mname) is blank, I don't want 2 spaces between fname and lname.
Here is my feeble attempt to make the command button do my bidding:
Of course, it doesn't work. I get runtime error 424 Object required. I'm sure there's a huge chunk of code I don't have a clue about but I want to learn. Any help would be greatly appreciated.
seangefferson
I'm totally new to Access and so my question may be so basic it's embarassing but here goes.
I have created a form with 4 fields on it:
fname
mname
lname
display_name
I want the user to enter the customer name in the first 3 fields and then have a command button to fill the display_name field with the first three fields concatenated. But, if the middle name (mname) is blank, I don't want 2 spaces between fname and lname.
Here is my feeble attempt to make the command button do my bidding:
Code:
Private Sub cmdDisplayName_Click()
If Mname Is Null Then
Display_Name.Value = Fname + " " + Lname
ElseIf Mname Is Not Null Then
Display_Name.Value = Fname + " " + Mname + " " + Lname
End If
End Sub
Of course, it doesn't work. I get runtime error 424 Object required. I'm sure there's a huge chunk of code I don't have a clue about but I want to learn. Any help would be greatly appreciated.
seangefferson