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

Subform to another form 1

Status
Not open for further replies.

Fireman1143

IS-IT--Management
Mar 5, 2002
51
US
Good day!

I have an application in which I use a button to send the user form the list of Contracts to the one they selected with the button. The DetailButton code is below. This same coding works in all sections EXCEPT for the Contracts ( I also have Licenses, Software, Systems, Peripherals etc all work)

When the button is clicked, an Access input box pops up and has the ContractNumber where we would put the question. If I put that same number in the input area of the box, it takes me to the correct Contract) I can not figure why the box is appearing and have tried re-writing the stLinkCriteria various ways. The form names and field names are correct.

Any thoughts or does someone see my error?


Private Sub DetailButton_Click()
On Error GoTo Err_DetailButton_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmContracts" :The form I am opening
stLinkCriteria = "[ContractNumber] =" & Me![ContractNumber] :The Contract Number is used for selection and has the same name on both forms

DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_DetailButton_Click:
Exit Sub

Err_DetailButton_Click:
MsgBox Err.Description
Resume Exit_DetailButton_Click

End Sub


Thanks,
Fireman1143
 
How are ya Fireman1143 . . . . .

I could be wrong, but it sounds like a parameter input box is popping up.

Check your referemce for [blue]Me![ContractNumber][/blue]. For instance . . . . If the button is on a subform and ContractNumber is on the main form or vice versa, the referencing would be incorrect and raise the parameter input window. Try full referencing, something like

[blue]Forms!MainFormName!subFormName.Form!ContractNumber[/blue] for referencing subform & [blue]Forms!MainFormName [/blue]for referencing main form.

Calvin.gif
See Ya! . . . . . .
 
Thanks TheAceMan1 I believe that information has me on the right track. It is a parmeter popup box which has the Contract Number and if the same number (a text field) is entered it brings up the correct contract.

I have tried your suggestion and variations of it but still get it. I belive I just need to step through it and use your information.

Fireman1143

 
Fireman1143 . . . . .

Just incase [blue]ContractNumber[/blue] is type [blue]Text[/blue], the correct format for criteria is below:

Code:
[blue]stLinkCriteria = "[ContractNumber] = [purple][b]'[/b][/purple]" & Me![ContractNumber] & "[purple][b]'[/b][/purple]"[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top