Populating text boxes base on a separate combobox selection

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

Guest

I have a subform in which a user selects a department to post revenue to from
a combo box. I am trying to get the department's accounting unit, and
activity number to populate separate text boxes on the same sub-form. Here
is the coding that I'm using:

Private Sub Name_LostFocus()
SMF_AU = Me.Name.Column(5)
Activity_Number = Me.Name.Column(4)
End Sub

I continually get an invalid qualifier error on this. Any help would be
appreciated.
 
Is "Name" the name of your combobox control? That is most
likely your problem as "Name" is also a property of "Me",
your form which would really confuse Access. Try renaming
your combobox to cboName or something similar. It would also
be wise to rename the underlying field if possible as well
as you will probably continue to have glitches due to using
a reserved name.

If you put either of these lines in your code it should
display the name of the form.

Msgbox Me.Name

Debug.Print Me.Name

While renaming the control should have precedence, this
modification would probably work as well.

SMF_AU = Me("Name").Column(5)

--
Gary Miller
Sisters, OR



"Buffalo Finance" <Buffalo
(e-mail address removed)> wrote in message
news:D[email protected]...
 
The Name is a reserved name in Access, it better to change it to a different
name, it will be OK to use it, as long that you put it in square brackes

Me.SMF_AU = Me.[Name].Column(5)
Me.Activity_Number = Me.[Name].Column(4)
 
'Name' is an Access reserved word. Using such as field names can cause
unpredictable behavior. Also, the dot operator is for separating objects
from its methods and properties. Use the bang (!) operator to separate
objects from each other.

Also, although not strictly necessary, using control naming conventions and
bracket delimiters makes your code more self-explanatory:

SMF_AU = Me![cboYourNameCombo].Column(5)
Activity_Number = Me![cboYourNameCombo].Column(4)

Hope that helps.
Sprinks
 
Back
Top