Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto populate field in form and write it to table 1

Status
Not open for further replies.

Spyridon

Technical User
Jun 27, 2003
45
US

First of all I want to say thank you to everyone on here who participates. I have been amazed not only at the depth of knowledge that many of you have, but the willingness to help each other out. Through many of your posts I've put together a database that almost works! woo hoo!

I'm needing a little bit of help putting on the last touch with my database though. I have a login form that takes a user name and password, checks to make sure that they are correct, and then appends them to a table called "LocalUser". When the login form is started, a delete query runs and deletes everything in the table "LocalUser", and then the append query runs.

In my append query I have a DLookup expression finding a value from a field in another table.
DLookUp("[SalesID]","Employee","[Login] = [Forms]![Loginform]![txtlogin]")

Basically what I need written to the "LocalUser" table is the login, the user level, and the
SalesID. All of these are in the "Employee" table. All of this works just fine; where my problem comes in is that I need the SalesID number from the "LocalUser" table to automatically populate into a form called "Sales". But the SalesID also needs to be written to the "Sales" table. So to put it simply, what I need is to have the appropriate SalesID automatically populate for the user who is logged in so that they don't have to type it in with every order. That SalesID is used to run reports later finding out how many sales such and such person with that SalesID number had. It seems like such a simple little thing, but I'm just not getting it.

I've tried various ways to make it work, putting the default value for the Sales.SalesID field as the above Dlookup expression. That didn't work. I tried making the default value for the Sales.SalesID field as LocalUser.SalesID, but that didn't work either. I tried a to do a lookup field in one of the tables. Actually, I've tried so many wrong things that I don't exactly remember what I've done. Although I am fairly certain that I haven't done one thing, the RIGHT WAY TO DO IT!

Anyway, thanks to anyone who can help.


Michael
 
Michael,

Why not do this with simple VB code. If you need a sample of how it might be done, send me your email address.

I would:

1) open the main table
2) open the localuser table and delete all records
3) loop through the main table and when the proper ID hit is recognised, add that record to the local table with a for/ next loop using the rs.fields(i) = rs2.fields(i) to fill all the fields.

rollie@bwsys.net
 
Hey thanks Rolliee,

I just sent you an email, but just in case, my email address is spyridon@comcast.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top