Open up another form by click a button

richardplr

Registered User.
Local time
Tomorrow, 04:43
Joined
Jun 10, 2003
Messages
239
Hi,

I have a form and on the form, I have added a button.
when click, it will open another form and link and will show all the relate
link data.

Can anyone help.
 

Attachments

Rich said:
Use the Button Wizard, it'll create the code for you

I have tried, it can open up everything of another form but I want to know what is the code, if it selective of supplier code.

So, I will go to the supplier masterlist say the supplier code is SPD, then when I click the button, it should give me the datalist of another form what relate to spd only.

Can someone help please.

:eek:
 
Maybe you can try this code:

Code:
Private Sub [COLOR=Red]cmdButtonName[/COLOR]_Click()
On Error GoTo Exit_[COLOR=Red]cmdButtonName[/COLOR]_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "[COLOR=Red]FormName[/COLOR]"
stLinkCriteria = "[[COLOR=Red]SuppID[/COLOR]]= '" & [COLOR=Red]cmbSuppID [/COLOR] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_[COLOR=Red]cmdButtonName[/COLOR]_Click:
Exit Sub

Err_[COLOR=Red]cmdButtonName[/COLOR]_Click:
MsgBox Err.Description
Resume Exit_[COLOR=Red]cmdButtonName[/COLOR]_Click

End Sub

I am not sure if it helps. For your reference, change the code coloured in red to suit your forms. Your other form should be in continuous form, or else it will only displays only one record eventhough there are more than 1. Good Luck
 
klwu said:
Maybe you can try this code:

Code:
Private Sub [COLOR=Red]cmdButtonName[/COLOR]_Click()
On Error GoTo Exit_[COLOR=Red]cmdButtonName[/COLOR]_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "[COLOR=Red]FormName[/COLOR]"
stLinkCriteria = "[[COLOR=Red]SuppID[/COLOR]]= '" & [COLOR=Red]cmbSuppID [/COLOR] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_[COLOR=Red]cmdButtonName[/COLOR]_Click:
Exit Sub

Err_[COLOR=Red]cmdButtonName[/COLOR]_Click:
MsgBox Err.Description
Resume Exit_[COLOR=Red]cmdButtonName[/COLOR]_Click

End Sub

I am not sure if it helps. For your reference, change the code coloured in red to suit your forms. Your other form should be in continuous form, or else it will only displays only one record eventhough there are more than 1. Good Luck

Still won't work. Don;t know where went wrong.

Anyway, really thank you for your hardwork.

Thankyou
 
why not post the code that you do have, and the relevant text box/field names etc.
 

Users who are viewing this thread

Back
Top Bottom