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

Adding record in Access form with filtered data

Status
Not open for further replies.

bearatc

Technical User
Sep 26, 2011
6
0
0
US
I have an Access form that I am having trouble assigning a specific value to a field in that form. I have mostly used the wizards to create a lot of my forms, so I only have minimal experience with VBA coding. I will try to give the clearest picture on what I’m trying to do.

From “Form1” I added a button to open “Form2”. By using the wizards to create the “Form2”, when “Form2” opens, it has filtered the records based on the field “MemberID”. “Form1” is based on a “Table1” that has the field “MemberID” in it and “Form2” is based on “Table2” and it also has a field “MemberID” in it, so it can be used to link the two tables.

Once “Form2” opens from “Form1”, it displays the filtered records as it should. I want to add records to “Form2”. I created a button from the wizards to add a new record, but I want the button to also fill in the “MemberID” on “Form2” that is the same as the “MemberID” that was used to filter the data from “Form1”. Here is the only code that is on the Button on “Form2”. What code do I need to add so that the “MemberID” from “Form1” is placed in the “MemberID” field in the new record on “Form2”?


Private Sub AddBut_Click()
On Error GoTo Err_AddBut_Click

DoCmd.GoToRecord , , acNewRec


Exit_AddBut_Click:
Exit Sub

Err_AddBut_Click:
MsgBox Err.Description
Resume Exit_AddBut_Click

End Sub
 


hi,

Please post MS Access FORMS questions in forum702, MS Access VBA questions in forum705

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top