Opening New Form

H

Hank

I have 2 forms that are tied to the same record. My Key Field is a Customer
Order Number That is Created on the Fly but not autonumber. I didn't use the
2nd. form as a subform because it is as large as the 1st. and really would
not apply to the scheme of things. If I open the 1st. form in edit view and
use the button to navigate to the 2nd. form all is okay. But if I am entering
a New Record, the 2nd form does not populate the Table. How do I adjust my
coding for this. I am kinda lost here. Code for the button follows:

Private Sub Command235_Click()
On Error GoTo Err_Command235_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Logistics & Routing"

stLinkCriteria = "[CustOrderNum]=" & Me![BillOfLadingTxt]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command235_Click:
Exit Sub

Err_Command235_Click:
MsgBox Err.Description
Resume Exit_Command235_Click

End Sub

Thanks
 
J

John W. Vinson

I have 2 forms that are tied to the same record. My Key Field is a Customer
Order Number That is Created on the Fly but not autonumber. I didn't use the
2nd. form as a subform because it is as large as the 1st. and really would
not apply to the scheme of things. If I open the 1st. form in edit view and
use the button to navigate to the 2nd. form all is okay. But if I am entering
a New Record, the 2nd form does not populate the Table. How do I adjust my
coding for this. I am kinda lost here. Code for the button follows:

If the record is still open on the first form then it isn't really "there"
yet. You can explicitly save the record to disk prior to opening the form;
there are two commands that will do this -

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False


Put one or other of these lines before the DoCmd.OpenForm line in your code
and you should be ok.

I would really suggest changing the name of your command button and the
function to match (say from Command235 to cmdLogisticsRouting); six weeks from
now you'll be looking at this code and wondering "wotinell is Command235...!?"
Private Sub Command235_Click()
On Error GoTo Err_Command235_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Logistics & Routing"

stLinkCriteria = "[CustOrderNum]=" & Me![BillOfLadingTxt]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command235_Click:
Exit Sub

Err_Command235_Click:
MsgBox Err.Description
Resume Exit_Command235_Click

End Sub

Thanks
 
H

Hank

Thank You So Much !!!!!!!!!!!
John W. Vinson said:
I have 2 forms that are tied to the same record. My Key Field is a Customer
Order Number That is Created on the Fly but not autonumber. I didn't use the
2nd. form as a subform because it is as large as the 1st. and really would
not apply to the scheme of things. If I open the 1st. form in edit view and
use the button to navigate to the 2nd. form all is okay. But if I am entering
a New Record, the 2nd form does not populate the Table. How do I adjust my
coding for this. I am kinda lost here. Code for the button follows:

If the record is still open on the first form then it isn't really "there"
yet. You can explicitly save the record to disk prior to opening the form;
there are two commands that will do this -

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False


Put one or other of these lines before the DoCmd.OpenForm line in your code
and you should be ok.

I would really suggest changing the name of your command button and the
function to match (say from Command235 to cmdLogisticsRouting); six weeks from
now you'll be looking at this code and wondering "wotinell is Command235...!?"
Private Sub Command235_Click()
On Error GoTo Err_Command235_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Logistics & Routing"

stLinkCriteria = "[CustOrderNum]=" & Me![BillOfLadingTxt]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command235_Click:
Exit Sub

Err_Command235_Click:
MsgBox Err.Description
Resume Exit_Command235_Click

End Sub

Thanks
 

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