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!

Need Practical Easy Example Of Passing Data Between Forms 1

Status
Not open for further replies.

BTurner0606

Programmer
Dec 21, 2000
4
US
I am new to Access programming and I am sure this is not very difficult, but I am having trouble understanding how to implement it. I need help with the coding needed on the Openform for form_Family and needed coding for form_Visit.

I am up against a deadline and any help would be greatly appreciated.

I have the following scenario:

tbl_Family
FamilyID Integer
MemberNumber Integer
FirstName Text
LastName Text
BirthDate Date
---------------------------------------
tbl_Visit_Data
FamilyID Integer
MemberNumber Integer
VisitDate Date
Address Text
Telephone Text
---------------------------------------
form_Family
TextBox FamilyID
TextBox MemberNumber
TextBox FirstName
TextBox LastName
TextBox Birthdate
CommandButton "Visit Info"
---------------------------------------
form_Visit
TextBox FamilyID
TextBox MemberNumber
TextBox FirstName
TextBox LastName
TextBox BirthDate
TextBox VisitDate
TextBox Address
TextBox Telephone
---------------------------------------

When I click the CommandButton on form_Family, I want to pass the FamilyID and MemberNumber to form_Visit. Then I want FirstName, LastName and BirthDate to be automatically populated with data from the tbl_Family. I will enter VisitDate, Address and Telephone to complete the data entry.


Bently Turner
bturner@wi.rr.com
 
Hi Bently,

What I did in a similar situation is create my variables in a module so they can be shared between forms.

So create variables that will hold the data you want to carry over. Then once the form is filled in and the user clicks a button, have the event in the button copy the data in the fields to the variables. Then have it open the next form with a new record. Then have it copy the data in the variables to the fields required.

Then use Dlookup function in the Changed event of the last field copied to populate the remaining fields as needed.

If you want more detailed info on how to do it, let me know.

HTH

Mary :)
 
There is the option of using a subform. I presume you have a one-to-many relationship between tbl_Family and tbl_Visit_Data based on the FamilyID and MemberNumber. If this is the case then you can have a form with the Family Data which contains a subform with a list of the visits. In this way you can add your visits without leaving the form and also Access will automatically add in the FamilyID and MemberID for you. This is probably the best way to do it but if you haven't got the time to look into it I have a couple more suggestions.
Firstly, you could use the openargs property of the form. When you open form_Visit use the optional OpenArgs parameter in the Docmd.OpenForm function. You can pass in your FamilyID and MemberNumber with this and then populate your controls in the Load event of form_Visit.
My last suggestion is to use the forms collection. You can directly reference another form and it's controls using this. The following line would fill the FirstName textbox on form_Visit (you can do the same for all the other fields)

Code:
me.FirstName = Forms!Form_Family.Controls!FirstName.Value

If you're still stuck then I'm sorry, I can't help you any more because I live in the Southern Hemisphere and I'm off to the beach for the next two weeks.B-)
Happy Christmas
Durkin
alandurkin@bigpond.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top