Open second form based on info in first.

esskaykay

Registered User.
Local time
Today, 22:59
Joined
Mar 8, 2003
Messages
267
I have a Form1 that is based on a select query with a criteria [Enter PIN number]. When we enter the PIN it returns the correct result. I want to have a button that opens a second form based on the same PIN number entered to open the first (in fact there will be numerous forms I want opened based on this PIN).

Example:

Sidewalk - button
Curb X button
Tree - button
Hydrant X button


In the example above, only CURB and HYDRANT returned an entry. Therefore when I click on the button next to CURB I'd like the frmCurb to open showing the data based on the PIN numbered entered to open the From1, and when I click on the button next to HYDRANT it would open frmHydrant showing the data for HYDRANT based on the same PIN number entered to open the Form1.


Thanks,
SKK
 
SKK,

DoCmd.OpenForm "ThatForm",,,"[PIN] = " & Me.PIN

Wayne
 
Have a look at the attached sample.
 
Last edited:
I tried both suggestions to no avail. I received an error "Undefined function chr".

On the other suggestions I receive Run time error 424 Object Required.

Here is my code (modified slightly):

Private Sub cmdCUP_Click()
DoCmd.OpenForm "frmCUP", , , "[ParID] = " & tblCUP.ParID
DoCmd.Close
End Sub

Thanks,
SKK
 
SKK,

Below, you refer to: tblCUP.ParID

You are using the value from your current form (not a table), it should
be Me.ParID.

Code:
Private Sub cmdCUP_Click()
DoCmd.OpenForm "frmCUP", , , "[ParID] = " & tblCUP.ParID
DoCmd.Close
End Sub

Wayne
 
So if I code:

Private Sub cmdCUP_Click()
DoCmd.OpenForm "frmCUP", , , "[ParID] = " & Me.ParID
DoCmd.Close
End Sub

I get Run time error 2501
Operation form action was canceled.

Thanks,
SKK
 
The correct code (just put in your control and form name) is in my sample behind the Contract Button on the frmCusGeneric. That is why I sent it so tha you could see how it works and modify yours to suit.

Is ParID a number or Text? (in both tables)
 
John,

I think that we might be trying to open the same form.

SKK Help?

Wayne
 
Wayne,

You think that he is trying to open FrmCUP from frmCUP.

ah well he has my best wishes....he will need all the help he can get.
 
I'm trying to open frmCUP from Form1

Both fields are text


SKK
 
Here is the answer to you problem:

Numbers:

"[Criteria] = " & Me.[MyNumber]

stLinkCriteria = "[ CustomerID]=" & Me![CustomerID] (Example)


Text:

"[Criteria] = '" & Me.[MyText] & "'"

stLinkCriteria = "[cusName]=" & "'" & Me![cusName] & "'" (Example)


Date:

"[Criteria] = #" & Me.[MyDate] & "#"

PS Just a question, did you at least open my sample I sent you? I find that after spending time to do the sample for you the least you could do is acknowledge me or the sample in one of your requests for more help.
 
John A.

Like I noted previously, yes I did open the sample TwoForms but received an error message. I did not have a chance to get back to this to try your latest suggestion (including modifying the code attached to the Contact button), but most certainly will do very soon.

In the future, I will definitly make sure I respond more promptly and sincerely. I truly do appreciate all your help. It's not like I'm ungrateful. If it wasn't for forums like this I'd be totally lost. You guys are what keep us neophytes (aka morons) in business. I hope I didn't upset you too much. It's just that we've got a few other projects going on here, sorry.

Again, thank you very much for your support. It truly is held in great regards...

SKK
 

Users who are viewing this thread

Back
Top Bottom