Forename and Surname

Charlie2

Registered User.
Local time
Today, 15:55
Joined
Mar 28, 2002
Messages
79
Im working with a form and want to include the staff members forename and surname in a textbox next to the checked by box. In the properties i can select either forename or surname but not both. I thought about the expression builder and tried using Staff Forename And Staff Surname but this did not work.
How can I get both parts of the name to display?

charlie
 
Ive Tried

Ive tried to use =[First Name]& " " &[Surname] in the control source of the text box but all I get is #Name?

So does anyone know what the problem is.


Charlie
 
Charlie -

Your code is going in the right direction, but where are the Surname and FirstName coming from? Are those fields in the Field list for the form or are they coming from a combo box or list box?

Jack
 
Re:

The First Name and Surname are in the tblStaff. I already have a combo box on my form that displays the code and staff names. It goes like this, SELECT tblStaff.[Staff Code], tblStaff.[Staff Forename], tblStaff.[Staff Surname] FROM tblStaff;

I dont know if that is relevant though.

Charlie
 
Charlie -

Yep, that was relevant... In the After Update event of your combo box put code like this:

Me.UnboundControlOnForm = Me.NameOfComboBox.Column(1) & " " & Me.NameOfComboBox.Column(2)

Be sure and change the names above to the actual names of your combo box and unbound control.

hth,
Jack
 
did that

The text box shows the staff code in the display. the Initials eg: JJ.
In the combo box I have initials, First Name, surname.

Charlie
 
Bound

Has this text box got to be bound or unbound? If it is unbound it wont cycle records with the rest of the form will it.
at the moment it is bound to Processed by.

Charlie
 
Charlie -

Let me put it this way... If you have a list of people there should be a unique ID for everyone in the list, usually an autonumber. In your combo box you would have PersonsID, FirstName and LastName. The combo box would be bound to the ProcessedBy field in the form. This means that when you select Joe Bloggs from the combo box his ID is saved in the ProcessedBy field in the table. If you want to display his/her name on the form so people know who it is then you can use the code I suggested to fill an unbound control on the form.

I hope that I have made sense....

Jack
 
OK

The text box is unbound, and this is the code I put in the event procedure.

Me.UnboundControlOnForm = Me.Combo24.Column(1) & " " & Me.Combo24.Column(2)


when I use the form the box shows nothing, no error or names.

Charlie
 
Charlie -

The unbound control on your from has a name. Maybe Text17 or Text87 or something. Open the property sheet for the control and get the name the put that in the Me.UnboundControlOnForm part of the code. It might look like this:

Me.Text81= Me.Combo24.Column(1) & " " & Me.Combo24.Column(2)

Hang in there, you are getting close!

Jack
 
Still Blank

Private Sub txtFirstLast_AfterUpdate()
Me.txtFirstLast = Me.Combo24.Column(1) & " " & Me.Combo24.Column(2)


End Sub


I used this code and it remains blank, I think I am cursed. I am sure I have done this before too.

Charlie
 
Good news Charlie, you are not cursed! Put your line of code in the After Update event of the combo box... Your subroutine should look like this:

Private Sub Combo24_AfterUpdate()
Me.txtFirstLast = Me.Combo24.Column(1) & " " & Me.Combo24.Column(2)


End Sub

Now it will work...

Jack
 
Good and bad news

The good news is the name IS diplayed, the bad news is the name does not change with the rest of the form displaying different records.

Charlie
 
Charlie -

Ah, I did not realize that that was one of your goals.... Here you go....

1. Make a combo box using the Wizard and on the first screen select the 3rd item, "Find a record....".

2. Finish the Wizard and then take the line of code and place it after rs.bookmark bit of code.

I am unsure of the Record Source for your form so this may not work exactly as I have suggested. If it does not do what you want then let me know....

Jack
 
Its Ok Jack

I will do battle with it in the morning, eventually I will conquer it though.

Thanks for your time.

Charlie
 
OK Charlie. If you want you can email your db and I will take a look at it for you....

I should be around tomorrow...

Jack
 

Users who are viewing this thread

Back
Top Bottom