Automatically Fill In Field

ccflyer

Registered User.
Local time
Today, 09:04
Joined
Aug 12, 2005
Messages
90
Hi everybody,

I have a table that has 4 columns as shown below:

(*It really isn't code, I just couldn't figure out how else to keep the columns in place!)


Code:
-------------------------------------------------------------------
Store Name    Invoice Number   Customer Name   Customer Address
  Store1             1              Bob           PO Box 55
  Store1             2              Joe           PO Box 789
  Store2             3             Chris          PO Box 1254
-------------------------------------------------------------------
On my input form, for entering a new invoice, when you select the customer name, I want the form to automatically fill in the correct address in the "Customer Address" field.

I think there has to be a way to do this because there is only ever going to be one address for every customer. And the same customers will be comming back very often.

Does anyone have any ideas?

-Chris
 
Last edited:
Have the Wizard help you put a ComboBox on your form.
 
How do you get the combobox to enter the second column in a separate text box?

-Chris
 
In the AfterUpdate event of the ComboBox put:

Me.OtherTextBox = Me.ComboBox.Column(1)

ComboBoxes are zero based so (1) is the second column. Use your names of course.
 
What does the "Me" stand for in your code? Is it the name of the form?

-Chris
 
In this case it is the short form for the Form you are running on.
 
Sorry to keep asking about this, so I can leave it as "Me", or do I have to put my form name there?

-Chris
 
Just replace the Bold items with your names.

Me.OtherTextBox = Me.ComboBox.Column(1)
 
After I type that into the After Update Event box, and attempt to run it, I get an error message that says "Microsoft Office Access can't find the macro 'Me' ".

This is what I typed:

Me.State = Me.ComboBox.Column(1)

My text box is called 'State' and my combo box is called 'ComboBox'

-Chris
 
Go to the Event tab of the ComboBox and in the AfterUpdate line press the builder "..." - this puts you in the code section. That is where the code I posted belongs. Post back if you still have problems. By the way, convention is that you give your ComboBox a descriptive name preceeded by cbo:
cboEventSelection as an example. It will pay off later when you are trying to understand what the heck the code is doing.
 
Still problems;

First of all, I did rename my combo box to 'cboGetInfo', thanks for the tip. And second, my new problem is this:

When I build the expression with the expression builder it puts this text into the After Update box:

Code:
=Me.State=Me.cboGetInfo.Column(1)

Then when I try to run it again to see if it will work, It says
"The object doesn't contain the Automation object 'Me.' "

-Chris
 
I did not supply an expression. What I gave you was code to be executed in the event handler. In the same location on the Event tab of the properties form after you click in the box a button appears on the right side of the row with three dots "..." on it. Press it and create code.
 
It worked!!!

Thank you for helping me along in that process. I just have one more quick question for you now that it works. If I want to use a third column of the combo box along with the one we just made would I just put that code right under the current code in the code editor?

Like this:

Code:
Me.State = Me.cboGetInfo.Column(1)
Me.Location = me.cboGetInfo.Column(2)

-Chris
 
Thanks, I wouldn't have done it without you!

-Chris
 

Users who are viewing this thread

Back
Top Bottom