data on frm1 to show on frm2

B

brinalynn

I am new to Access so please be gently on your
explanations I am trying to do the following:

I have 2 forms both forms information are coming from
separate tables. I have a button on frm1(customer
details) to open frm2(forms status) linked by custID. I
am able to show the information for the current record in
frm1 on frm2 as long as the custID already exist in the
table for frm2.

I am having problems when I add a new record on frm1. I
would like certain fields from frm1 to show on frm2. For
example on frm1 I want the custID, custName, custPhone
fields to populate on frm2 in the appropriate text
boxes/labels. After updating the information on frm2 I
would like for it save to the table for frm2.

1. How do I get the new data on frm1 to show on frm2 when
it is opened? I am not sure if to get this to work should
be in the code or was there something I was to do when I
built my query for this form?
- AND -
2. Do I need to add a button on frm2 to have the data
save to the table for frm2?

This is the code I have thus far. Right now frm2 will
open with information that already exists in frm2 table.
If the custID does not exist in frm2 it will open with
all fields blank.

Private Sub cmdfrm2_Click()
On Error GoTo Err_ cmdfrm2_Click

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm2"

stLinkCriteria = "[CustID]=" & "'" & Me![CustomerID]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_ cmdfrm2_Click:
Exit Sub

Err_ cmdfrm2_Click:
MsgBox Err.Description
Resume Exit_ cmdfrm2_Click
End Sub

Any Help would be greatly appreciated!!
 
J

John Vinson

I have 2 forms both forms information are coming from
separate tables. I have a button on frm1(customer
details) to open frm2(forms status) linked by custID. I
am able to show the information for the current record in
frm1 on frm2 as long as the custID already exist in the
table for frm2.

Have you considered the idea of making frm2 a Subform (perhaps on a
tab page if you need the screen space) of frm1? This would let you see
records from both tables simultaneously, maintain the link, allow the
addition of new records, and keep the link between the tables. No code
needed at all!
 
G

Guest

-----Original Message-----


Have you considered the idea of making frm2 a Subform (perhaps on a
tab page if you need the screen space) of frm1? This would let you see
records from both tables simultaneously, maintain the link, allow the
addition of new records, and keep the link between the tables. No code
needed at all!


.
So instead of having a button on frm1 I should make frm2
a subform. The only link I have is in the code for the
button and that was created during the wizzard.
When I try to link the two tables holding the information
for frm1 and frm2 I get an error "TYPE MISMATCH IN
EXPRESSION". I am not sure what that means exactly. I
linked the two tables on the custID. On the table for
frm1 the custID is an autonumber and the table for frm2
it is number!
 
J

John Vinson

So instead of having a button on frm1 I should make frm2
a subform. The only link I have is in the code for the
button and that was created during the wizzard.
When I try to link the two tables holding the information
for frm1 and frm2 I get an error "TYPE MISMATCH IN
EXPRESSION". I am not sure what that means exactly. I
linked the two tables on the custID. On the table for
frm1 the custID is an autonumber and the table for frm2
it is number!

Check the second table's definition. An Autonumber is a specialized
Long Integer - make sure that the linking field in the second table is
Number, *Long Integer* (rather than one of the other number datatypes
such as Integer or Float or Double).
 
B

brinalynn

Thank you That worked fine.
-----Original Message-----


Check the second table's definition. An Autonumber is a specialized
Long Integer - make sure that the linking field in the second table is
Number, *Long Integer* (rather than one of the other number datatypes
such as Integer or Float or Double).


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top