By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

How to auto-populate fields in an MS Access Form with VB?

P: 4
I am running Windows XP, Access 2002.
I want to know the VB code for the following:
I want to type in the ID # (it's the primary key and is auto-numbering) and then have the access form autopopulate three fields for that ID # record. (The three fields are called pu, am, and qu). Pu should populate with a vaule of 1. Am should populate with a value of 38. Qu should populate with a value of 1.
Can you please send me the code?
Thank you!
Mar 14 '07 #1
Share this Question
Share on Google+
8 Replies


100+
P: 1,646
Moved your thread to the Access forum
Mar 14 '07 #2

P: 4
I know how to open VB within Access. What I don't know is how to write code! Can you please help me?
Mar 16 '07 #3

100+
P: 1,646
I know how to open VB within Access. What I don't know is how to write code! Can you please help me?
In Access the language is VBA which is different from vb so this is the correct forum for your question
Mar 16 '07 #4

Denburt
Expert 100+
P: 1,356
Sounds like you are just looking to set the default property. Right click on the control and go to properties then look for the default value.

If you wanted these values to change for whatever reason you could use the "On Current" event and insert the code for it in there.

Let me know if you need more specifics.
Mar 16 '07 #5

P: 4
I can't just set a default code because it won't be for every record. Just after a certain point in time, I want to type a record ID number and then have it auto populate for that one record only. Can anyone help me write the code for that?
Mar 28 '07 #6

Denburt
Expert 100+
P: 1,356
I want to type in the ID # (it's the primary key and is auto-numbering)
You can not enter anything into a autonumber field since it generates the numbers for you.

[quote]I can't just set a default code because it won't be for every record. Just after a certain point in time, I want to type a record ID number and then have it auto populate for that one record only. Can anyone help me write the code for that?[/QUOTE}

You really need to be a bit more specific I don't understand what you are saying. It would help if we knew how those figures might change and for what reason.
Mar 29 '07 #7

P: 4
I am NOT trying to change the field that autonumbers.
After I type in the ID # (which is the autonumber) there are several fields for that record. I want then to autopopulate three fields for that ID # record.
(The three fields are called pu, am, and qu).
Pu should populate with a value of 1 (true).
Am should populate with a value of 38
Qu should populate with a value of 1

I will need to change it at times so that:
Am will populate with a value of 60
and Qu will populate with a value of 2

These fields do not have any default vaule, and they are not autonumbered.
Mar 30 '07 #8

Denburt
Expert 100+
P: 1,356
Well you could store your values in a table a set up a form so you can change these values anytime you want. Then have the default values of these controls reference that table.... I still may not fully understand, but this is one approach.
Mar 31 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.