Auto Fill In of form fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I took Ken's advice and looked on his webpage for the above, but have not
been able to get the event procedure to work. Here is the text of my
AfterEvent:

Private Sub FileNumber_AfterUpdate()
Me.txtLastName.Value = Me.cboFileNumber.Column(1)
Me.txtFirstName.Value = Me.cboFileNumber.Column(2)
End Sub

(BTW, I tried the above without the ".Value" as well, still didn't work.)

The combo box is there and displays the values I want it to show, but when I
select the correct fileNumber of the person I wish to choose, it only
displays in the FileNumber field, not in either LastName or FirstName.

I then tried to do it with unbound boxes with the control source listed as

=cboFileNumber.Column(1)
=cboFileNumber.Column(2)

for LastName and FirstName respectively and just get the error message
"#Name?" in the box, no data.

What am I doing wrong?
 
Is the combo box - cboFileNumber linked to the text box - FileNumber?
If so you need to refresh the combo after updating the text box
Private Sub FileNumber_AfterUpdate()
Me.cboFileNumber.requery
Me.txtLastName.Value = Me.cboFileNumber.Column(1)
Me.txtFirstName.Value = Me.cboFileNumber.Column(2)
End Sub
 
Thanks Ofer,

I tried what you recommended and it still doesn't work. I'm wondering if
there is something wrong with my tables somewhere...

Any other ideas for troubleshooting?

MEOlsen
 
Please clarify something:
- Per your code, your event is FileNumber_AfterUpdate, so you have a
control named FileNumber?
- Per your code, you also have a combobox named cboFileNumber

Any chance one of those is wrong? Any chance your event is pointing to a
non-existant control "FileNumber", (which means it will never fire)?

Just to be sure, put the following in your AfterUpdate event & then run the
form. If you don't see a message when expected then you probably just need
to get your form controls & support code "connected" again.
MsgBox "FileNumber_AfterUpdate"

If that does work, are you sure a control named cboFileNumber exists?
(That's one possible explanation for #Name errors).

HTH,
 
George, THANKS!

Your post got me to thinking, and I retraced my steps and found that the
original name of the combo box was cboFile_Number (DUH...). Thats why putting
spaces in control titles is frowned upon, right?

It works now, so thanks for the idea.

MEOlsen
 
Does this afterupdate code work with sql tables? I tested this in an access
table and it worked but when I put the code for a sql table it didn't work.
Any help is appreciated.
 
Back
Top