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!

Loading default data into a popup form 1

Status
Not open for further replies.

OsoRojo

Programmer
Mar 5, 2003
4
US
I am tring to link a main customer form with a shipto form by the account number. The main form is based on a table that is linked to the shipto by the account number. When the user clicks on the shipto button if there are entries in the shipto table I would like then to appear, if not then just put the account number in the field and let the user add the data. I have tried forms!frmCustomer!txtACC in the data field on the shipto form but no joy.
Thanks
The Bear
 
The quick way would be to use the command button wizard to open the form based upon a value in the current form . i.e. the account number field. That should open the new form with the account number matched and whatever data in the shipto table record in the new form.

If you want to post the code behind your button, we can figure out what is wrong. - - - -

Bryan
 
Here are the two chuncks of code behind the forms:

Main form calling the shipto form

Private Sub cmdShipTo_Click()
On Error GoTo Err_cmdShipTo_Click
Dim stDocName As String
stDocName = "frmShipTo"
DoCmd.OpenForm stDocName, , , , acFormEdit, , Me![ACC]
Exit_cmdShipTo_Click:
Exit Sub
Err_cmdShipTo_Click:
MsgBox Err.Description
Resume Exit_cmdShipTo_Click
End Sub

Inn the ShipTo form


Private Sub Form_Open(Cancel As Integer)
'on open use OpenArgs to set the acc #
Forms!frmEditCustomer!txtACC = Forms!frmShipTo_OpenArgs
End Sub
I think it has to to with not finding a record in the shipto table. But I don't want the user to be able to put in a incorrect number.
Thanks
The Bear
 
This is how I would do it. I've done this in a working app, and when there is no record on the 'many' side (ShipTo, in your case), it will open a blank form with only the linked field filled in.

I set the link criteria as a variable (string), which helps me avoid syntax errors in the OpenForm line

- - -
stDocName = "frmShipTo"
stLinkCriteria = "[txtACC]=" & "'" & Me![txtACC] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria
- - -

On Load of new form . . change one bang to a '.', also I don't use OpenArgs . .I just directly link the fields .

- - -
Forms!frmEditCustomer.txtACC = Forms!frmShipTo.txtACC
- - -

Bry - - - -

Bryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top