Link to home
Start Free TrialLog in
Avatar of M M
M M

asked on

auto-fill field(s) in Access data entry form

Best way to autofill RepID & DeptID in a data entry form, based on  LNameRep & DeptName fields respectively.
The LNameRep & DeptName fields have a drop down list of choices.

When LNameRep is chosen, I would like the RepID to auto fill and
When DeptName is selected from drop down, I would like DeptID to auto fill.
(Easier to remember a name than a number regarding data entry.)

Hope there's an easy fix NOT involving having to edit tbls or qrys, that could potentially disturb other qrys?!!!!

Thank you for any input in advance.
Avatar of PatHartman
PatHartman
Flag of United States of America image

When you create a combo, the RowSource typically contains two columns, the PK which is the numeric identifier and a text field which is the description.  By using the column widths, you hide the ID and show the text but the ID is what gets stored.  Forms usually only show the text field. They almost never show the ID field so unless you need to show both, just fix the combo.  The easiest solution is probably to delete the combo and rebuild it using the wizard.
Avatar of M M
M M

ASKER

Hi Pat =)
OK, you must be a glutton for punishment - LOL!
This is my first stab at forms ...  I just dumped most all of the fields into form via wizard.  The combo box is the drop downs?  Sorry not a good grasp on terminology yet.  Here's what I have:
User generated image
Avatar of M M

ASKER

For the LNameRep, I have all my reps names, and for the DeptName, I have 4 dept names.  I thought ater I would need to rearrange/tab stops etc,.  My hopes is that eventually the reps could enter their own orders.  But that is waaaay down the road.  Need to do alot of rep-proofing before that happens -- lol.
Avatar of M M

ASKER

I did some googling as well, but not sure I can MODIFY a qryQuotes (& subsequently a qrySales as well), already created to do this ... IF I even understand this ... https://www.linkedin.com/pulse/autofill-form-microsoft-access-tim-miles.

Re-read your comment, and earlier when trying to enter in just LNameRep, checking the tblQuotes, it just left the RepID blank, so that's why I thought I had to include the numeric IDs in the form.  Hope that makes sense?
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of M M

ASKER

Hokey smokeys!  WHERE does one learn that?!  I have Access 2016 Bible, Access for Dummies.
Thank you for your yellow highlighter too!!!!  I don't know how you do that either!

I went to try this and got interrupted, will try later with less interruptions and let you know.

In the meantime ... as always, thank you so much.
If you had let the wizard create the combo, these are the settings it would have chosen (except for the Limit to List = Yes and Allow Value List Edits = No).

The tool I used to capture the image was the Snipping Tool which is built into Windows.  I'm using Win 10 but I'm pretty sure the tool was in Win 7 also.  Once you capture the image, you can use a pen and highlighter to mark it up.  Because I needed to capture two images, I created a word document and pasted in the first image and then pasted in the second and finally used the snipping tool to capture the two images at once from the word doc.

As to how I learned this stuff - trial and error and lots of pain, hair loss, and sleepless nights.  My criteria for purchasing a book is - can it answer at least three questions I have or show me how to do something new.  Of course with brick and mortar stores carrying fewer and fewer technical books, it is harder to weed out the good books.
Avatar of M M

ASKER

OK, stupid qtns!

Are those propty settings to convert my RepID & DeptID boxes (vs LNameRep & DeptName boxes) to combo boxes, y/n?

What is "cboUtility"?  Do I substitute in LNameRep & DeptName where I see it?  Likewise where I see UtilityID, it would be RepID or DeptID?
Since I copied this picture from MY database, the pictures show names of MY controls and MY query.  Yours will be your own names.  Put the form into design view and then Just click on the LNameRep field to select it.  At the right edge of the screen will be the properties of the control.   Change the tab as necessary to see the Format and Data tabs because those are what control how the combo works.  Your own control name will show in the top box.  Your own query or SQL string will show in the RowSource.  If your RowSource query selects more than two columns, you will need to change the ColumnCount and ColumnWidths properties to agree with YOUR query.
Avatar of M M

ASKER

thanks for that clarification.  (I think I had an Expert create a dummy scenario once as an example.)
currently, on my LNameRep field, on the data tab the row source type is value list, does that need to be changed to tbl/qry to be able to do the SELECT qry in row source?
I would never, ever use a Value List for data that is changeable.  Value lists are only suitable for data that either never or rarely needs to change.  Something like "sex" (although, we may see a rash of new entries in that list given the drive to "political correctness" in this country)  Create a table for your reps and use that table as the RowSource.
Avatar of M M

ASKER

LOL!!!  And he's funny too!

I think I did the value list in the beginning bc I couldn't figure out how to get a drop down list any other way ... sorry, it's kind of fuzzy -- too many trial & errors since I started this project a couple of months ago.  Eek, I'm prob going to find several issues going fwd that need attn bc I was unaware of best practices and such.

Will keep working, and keep you posted.  Gotta go for now.
She's funny ;)
Avatar of M M

ASKER

Good Good Friday!  I THINK I found this situation in Access Bible, p568, but not sure whether it's autofill per se?!  I'm going to study it ...
I would have never found it without your comments. (similar reference to setting col width to 0)

I know I've said this in previous posts (or at least THOUGHT it), but , it really does seem like a good part of the learning curve in Access is learning/knowing how/what to ask?!

Create a table for your reps and use that table as the RowSource.
?! Already had tblReps w RepID, LNameRep, FNameRep & Goal fields, so I JUST added DeptID & DeptName fields for the autofill purpose?! But now am lost ...
this fills LNameRep in tblQuotes, the underlying tbl, with a "1" (his RepID)?!  Need it to go in RepID field and preserve rep's last name.  Then 'rinse & repeat' - need to do same thing for DeptName ==> DeptID.  what am I missing?User generated image
Also, hopefully this isn't BIG issue, but I have used lNameRep in some tbls & rpts as I didn't know how to concatenate 2 months ago.  Now scared to try and correct it ... the domino thang!

If this gets too messy, I may have to finish this up at home ...

Thank you.  And Happy Easter if you're observing a 3-day wkend!
Avatar of M M

ASKER

For what it's worth ...

I think my value lists were created unwittingly when I created my tblQuotes & tblSales.  In the beginning I was using those tbls for data entry.  Each of those tbls have RepID & DeptID (PKs for their respective tbls) fields AND I added LNameRep and DeptName fields (both short text and are Display control: Combo Box, Row Source Type:Value List and Row Source: "**"; "**"; etc - ** whatever applicable choices for LNameRep or DeptName).

After I got the tbls established then I moved onto reports; and now I'm working on forms for data entry.
You don't store the rep's name in the quotes table.  You store his ID.  That means that when you run a report, you need to use a query to join the quote table to the rep table to pick up the rep's name.

The reason we don't store duplicate data is because it gets out of date.  For example, Suzie, your most prolific quoter gets married and changes her last name.  Do you want to change her name ONCE in the rep table or thousands of times in the quote table?

If you have both RepName and RepID in the quote table, get rid of RepName.
Avatar of M M

ASKER

OK, what can I say ... PatHartman has done it again!
I knew I should not have used LNameRep and DeptName in my tbls, but like I said,  at the start I didn't know how to concatenate ... and that was my cheat for data entry.

Now I am just psyching myself up to modify my tbls and hope I can pick up all the 'dominoes'!  Eeek!

Thanks again Pat!  Hope your Easter was good!

PS I did learn what 'cbo' is ... combo box .. woo hoo!  Man, there must be a more efficient way to learn ; )