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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autofilling a records with data from previous records

Status
Not open for further replies.

rodriga4

Programmer
Oct 19, 2003
2
US
Hi Everyone,

I would appreciate if you could help with a problem that I am having when I want to autofill some records with data from previous record. I tried few things but they didn't work, last thing I tried was using the following code in the after update event:
[Me].[fieldname].[DefaultValue]="'" & [Me].[fieldname].[Value] & "'" which I found on the threads in this site.

Thanks in advance for your help.
AR

 
Everyone,

I want to let you know that I was able to partially resolve the problem with the code below since it only worked for Text Box fields, but I would like it to work with Combo Box fields too. Could anyone help me with that?

Thanks,
AR
 
Say you have a customer table, with cust_ID, cust_Name, cust_Address, cust_City. etc.

You have an order form, which as fields for the customer and you want to have the customer fields to fill in automatically when you choose the customer ID from a combo box on the order form. Is that the type of thing you are looking for?

On you order form, put a combo box. Go thru the dialog boxes the wizard steps you through. You want to take the cust_ID from the customer table and store it on the cust_ID on the table you have your order form based on.
 
Hi:

There is an excellent article on Microsoft on how to do exactly what you want. I followed the instructions and it worked like a charm. Here's the link:


If you have problems with it, I'll post the code I used in the module and form.

Good luck.


[glasses][tt]Gus Brunston - Access2002(DAO Intermediate skills.
Webmaster: www.rentdex.com[/tt]
 
By the way, I found this solution and others on MS' sample program: "frmsmp00.mdb". (This is supposed to be for Access2000. It worked as well in AccessXP.)

[glasses][tt]Gus Brunston - Access2002(DAO Intermediate skills.
Webmaster: www.rentdex.com[/tt]
 
Hi all.

this works fine:
(put it after DoCmd.GoToRecord , , acNewRec or active it other way.)

Dim ctl As Control
For Each ctl In Screen.ActiveForm
If TypeOf ctl Is TextBox And ctl.Tag = "Somthing" Then ctl.SetFocus
SendKeys "^" & Chr(34), True
Next ctl

this will bring the data from previous record into each taged field "Somthing"
the "If" condition can be more complexe like:

If TypeOf ctl Is TextBox And ctl.Tag = "Somthing" and Left(ctl.Tag, 5) = "Somth" And ctl.Visible = True then ....

Good luck
CUOK



 
I am a beginner at Access so if this seems wrong please let me know but it seems to work fine for myself.

1)Review your tab order for your form.(Design View)

2)Create Command Button (CMDCOPYLASTRECORD) on your form.

3)Private Sub CMDCopyLastRecord_Click()
SendKeys "{tab}"
SendKeys "^{'}"
SendKeys "{tab}"
SendKeys "^{'}"
SendKeys "{tab}"
SendKeys "^{'}"
SendKeys "{tab}"
SendKeys "^{'}"

SendKeys "{tab}"
SendKeys "{tab}"

SendKeys "^{'}"
End Sub

4) If you don't want to copy a field then just tab over it!
If you have 25 feild then have 25 "{tab}" and "^{'}" in your code.

I have set up my Command so that if I want the last record copied I can control it with a "Click", if not then all fields are left blank. I have combo boxes,text boxes ect on my form.

In case you are wondering as I don't know how much you know the "^{'}" is the same as pressing CTRL and ' on your keyboard.Check out "Shortcut Keys" or "Send Keys" in the HELP. The "Send Keys" help file wasn't very clear to myself but I am a newbie to Access. Play around with commands to see what they do!


If anyone sees a problem with this then let me know to as I just figuered this out the other day.

Tormented
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top