opening a form from an open form and finding a specific record

G

Guest

I have a form where bookings are entered. Each booked order (each record) has
a button which opens a form that shows the purchase orders that are in place
for the specific order in the bookings table. The code for the button is:

Private Sub Command42_Click()
On Error GoTo Err_Command42_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBkingsPO"

stLinkCriteria = "[pojobnumber]=" & "'" & Me![bkjobno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

After opening the form frmBkingsPO I can select any line item on the
bookings form
and the frmBkingsPO form will update correctly. On the frmBkingsPO form I
have another button for each purchase order that is listed. This button opens
a purchase order entry form. So far I can get the purchase order entry form
to open, but I don't know how to get the specific corresponding purchase
order data to be displayed. The code for the button is:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Purchase Order Entry"

stLinkCriteria = "[ponumber]=" & Me![ponumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormPropertySettings

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

The purchase order entry form normally opens in data entry mode and is ready
for the entry of new data. On open the following code is executed.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Purchase Order Entry"
DoCmd.GoToRecord , , acNewRec
End Sub

This is for data entry of new purchase orders which is normally what happens.

What I want to do is open the purchase order entry form and display the
purchase order data associated with the record selected in the frmBkingsPO.
How can I overide the "on open" command and automatically go to the selected
frmBkingsPO record and display its unique data?
 
A

Arvin Meyer [MVP]

You need to open the form to the specific record, just as you did in the
earlier example. If there isn't one, the form will open empty, ready for a
new record. If there is one, you will need a button to go to the new record.
Delete or comment out the line:

DoCmd.GoToRecord , , acNewRec
 
G

Guest

Thanks for the quick response. I'm caught in a catch 22 situation - normally
I want the purchase order entry form to independantly open ready to accept
new data, but in the case of looking at the purchase order data from the
bookings side of things, I want to display a record. I thought there might
be a way to overide the default "on open" instruction.

Arvin Meyer said:
You need to open the form to the specific record, just as you did in the
earlier example. If there isn't one, the form will open empty, ready for a
new record. If there is one, you will need a button to go to the new record.
Delete or comment out the line:

DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
I have a form where bookings are entered. Each booked order (each record)
has
a button which opens a form that shows the purchase orders that are in
place
for the specific order in the bookings table. The code for the button is:

Private Sub Command42_Click()
On Error GoTo Err_Command42_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBkingsPO"

stLinkCriteria = "[pojobnumber]=" & "'" & Me![bkjobno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

After opening the form frmBkingsPO I can select any line item on the
bookings form
and the frmBkingsPO form will update correctly. On the frmBkingsPO form I
have another button for each purchase order that is listed. This button
opens
a purchase order entry form. So far I can get the purchase order entry
form
to open, but I don't know how to get the specific corresponding purchase
order data to be displayed. The code for the button is:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Purchase Order Entry"

stLinkCriteria = "[ponumber]=" & Me![ponumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormPropertySettings

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

The purchase order entry form normally opens in data entry mode and is
ready
for the entry of new data. On open the following code is executed.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Purchase Order Entry"
DoCmd.GoToRecord , , acNewRec
End Sub

This is for data entry of new purchase orders which is normally what
happens.

What I want to do is open the purchase order entry form and display the
purchase order data associated with the record selected in the
frmBkingsPO.
How can I overide the "on open" command and automatically go to the
selected
frmBkingsPO record and display its unique data?
 
G

Guest

Arvin,
You are exactly right - I commented out the
DoCmd.GoToRecord , , acNewRec
statement and the purchase order comes up with the correct data. If I could
figure out how to turn off, temporarily, acNewRec, I would have things
working ok. Any ideas?

Bobk said:
Thanks for the quick response. I'm caught in a catch 22 situation - normally
I want the purchase order entry form to independantly open ready to accept
new data, but in the case of looking at the purchase order data from the
bookings side of things, I want to display a record. I thought there might
be a way to overide the default "on open" instruction.

Arvin Meyer said:
You need to open the form to the specific record, just as you did in the
earlier example. If there isn't one, the form will open empty, ready for a
new record. If there is one, you will need a button to go to the new record.
Delete or comment out the line:

DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
I have a form where bookings are entered. Each booked order (each record)
has
a button which opens a form that shows the purchase orders that are in
place
for the specific order in the bookings table. The code for the button is:

Private Sub Command42_Click()
On Error GoTo Err_Command42_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBkingsPO"

stLinkCriteria = "[pojobnumber]=" & "'" & Me![bkjobno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

After opening the form frmBkingsPO I can select any line item on the
bookings form
and the frmBkingsPO form will update correctly. On the frmBkingsPO form I
have another button for each purchase order that is listed. This button
opens
a purchase order entry form. So far I can get the purchase order entry
form
to open, but I don't know how to get the specific corresponding purchase
order data to be displayed. The code for the button is:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Purchase Order Entry"

stLinkCriteria = "[ponumber]=" & Me![ponumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormPropertySettings

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

The purchase order entry form normally opens in data entry mode and is
ready
for the entry of new data. On open the following code is executed.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Purchase Order Entry"
DoCmd.GoToRecord , , acNewRec
End Sub

This is for data entry of new purchase orders which is normally what
happens.

What I want to do is open the purchase order entry form and display the
purchase order data associated with the record selected in the
frmBkingsPO.
How can I overide the "on open" command and automatically go to the
selected
frmBkingsPO record and display its unique data?
 
A

Arvin Meyer [MVP]

Despite what Hollywood would have you believe, Artificial Intelligence has
not progressed to the point of the computer intuitively knowing what you
want to do with your PO entry form. You have several choices, but all of
them will wind up branching some logic in your code.

1. You can use a dialog form and either a check box or an option group to
tell your form how to open.
2. You can have the calling form ask you how to open the PO entry form.
3. You can build 2 forms, but you still need to tell or be asked.

Code will look something like (for method 2):

If msgbox("Do you want a new PO?", vbYesNo, "POOpen type") = vbYes Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End If

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
Arvin,
You are exactly right - I commented out the
DoCmd.GoToRecord , , acNewRec
statement and the purchase order comes up with the correct data. If I
could
figure out how to turn off, temporarily, acNewRec, I would have things
working ok. Any ideas?

Bobk said:
Thanks for the quick response. I'm caught in a catch 22 situation -
normally
I want the purchase order entry form to independantly open ready to
accept
new data, but in the case of looking at the purchase order data from the
bookings side of things, I want to display a record. I thought there
might
be a way to overide the default "on open" instruction.

Arvin Meyer said:
You need to open the form to the specific record, just as you did in
the
earlier example. If there isn't one, the form will open empty, ready
for a
new record. If there is one, you will need a button to go to the new
record.
Delete or comment out the line:

DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I have a form where bookings are entered. Each booked order (each
record)
has
a button which opens a form that shows the purchase orders that are
in
place
for the specific order in the bookings table. The code for the button
is:

Private Sub Command42_Click()
On Error GoTo Err_Command42_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBkingsPO"

stLinkCriteria = "[pojobnumber]=" & "'" & Me![bkjobno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

After opening the form frmBkingsPO I can select any line item on the
bookings form
and the frmBkingsPO form will update correctly. On the frmBkingsPO
form I
have another button for each purchase order that is listed. This
button
opens
a purchase order entry form. So far I can get the purchase order
entry
form
to open, but I don't know how to get the specific corresponding
purchase
order data to be displayed. The code for the button is:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Purchase Order Entry"

stLinkCriteria = "[ponumber]=" & Me![ponumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormPropertySettings

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

The purchase order entry form normally opens in data entry mode and
is
ready
for the entry of new data. On open the following code is executed.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Purchase Order Entry"
DoCmd.GoToRecord , , acNewRec
End Sub

This is for data entry of new purchase orders which is normally what
happens.

What I want to do is open the purchase order entry form and display
the
purchase order data associated with the record selected in the
frmBkingsPO.
How can I overide the "on open" command and automatically go to the
selected
frmBkingsPO record and display its unique data?
 
G

Guest

I understand what you are saying. I came to the conclusion that a duplicate
form would be the solution. I thought there might be a way to open the
purchase order form and overide the "on open" instruction after the form is
open, but I think control goes to the form once it is open. Thanks for your
help.

Arvin Meyer said:
Despite what Hollywood would have you believe, Artificial Intelligence has
not progressed to the point of the computer intuitively knowing what you
want to do with your PO entry form. You have several choices, but all of
them will wind up branching some logic in your code.

1. You can use a dialog form and either a check box or an option group to
tell your form how to open.
2. You can have the calling form ask you how to open the PO entry form.
3. You can build 2 forms, but you still need to tell or be asked.

Code will look something like (for method 2):

If msgbox("Do you want a new PO?", vbYesNo, "POOpen type") = vbYes Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End If

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
Arvin,
You are exactly right - I commented out the
DoCmd.GoToRecord , , acNewRec
statement and the purchase order comes up with the correct data. If I
could
figure out how to turn off, temporarily, acNewRec, I would have things
working ok. Any ideas?

Bobk said:
Thanks for the quick response. I'm caught in a catch 22 situation -
normally
I want the purchase order entry form to independantly open ready to
accept
new data, but in the case of looking at the purchase order data from the
bookings side of things, I want to display a record. I thought there
might
be a way to overide the default "on open" instruction.

:

You need to open the form to the specific record, just as you did in
the
earlier example. If there isn't one, the form will open empty, ready
for a
new record. If there is one, you will need a button to go to the new
record.
Delete or comment out the line:

DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I have a form where bookings are entered. Each booked order (each
record)
has
a button which opens a form that shows the purchase orders that are
in
place
for the specific order in the bookings table. The code for the button
is:

Private Sub Command42_Click()
On Error GoTo Err_Command42_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBkingsPO"

stLinkCriteria = "[pojobnumber]=" & "'" & Me![bkjobno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

After opening the form frmBkingsPO I can select any line item on the
bookings form
and the frmBkingsPO form will update correctly. On the frmBkingsPO
form I
have another button for each purchase order that is listed. This
button
opens
a purchase order entry form. So far I can get the purchase order
entry
form
to open, but I don't know how to get the specific corresponding
purchase
order data to be displayed. The code for the button is:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Purchase Order Entry"

stLinkCriteria = "[ponumber]=" & Me![ponumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormPropertySettings

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

The purchase order entry form normally opens in data entry mode and
is
ready
for the entry of new data. On open the following code is executed.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Purchase Order Entry"
DoCmd.GoToRecord , , acNewRec
End Sub

This is for data entry of new purchase orders which is normally what
happens.

What I want to do is open the purchase order entry form and display
the
purchase order data associated with the record selected in the
frmBkingsPO.
How can I overide the "on open" command and automatically go to the
selected
frmBkingsPO record and display its unique data?
 
A

Arvin Meyer [MVP]

Two forms is only very slightly easier. You will, undoubtedly, appreciate a
single form if you need to make any changes. Now you must deal with the
changes on 2 forms (and making sure that your changes are the same).
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
I understand what you are saying. I came to the conclusion that a duplicate
form would be the solution. I thought there might be a way to open the
purchase order form and overide the "on open" instruction after the form
is
open, but I think control goes to the form once it is open. Thanks for
your
help.

Arvin Meyer said:
Despite what Hollywood would have you believe, Artificial Intelligence
has
not progressed to the point of the computer intuitively knowing what you
want to do with your PO entry form. You have several choices, but all of
them will wind up branching some logic in your code.

1. You can use a dialog form and either a check box or an option group to
tell your form how to open.
2. You can have the calling form ask you how to open the PO entry form.
3. You can build 2 forms, but you still need to tell or be asked.

Code will look something like (for method 2):

If msgbox("Do you want a new PO?", vbYesNo, "POOpen type") = vbYes Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End If

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
Arvin,
You are exactly right - I commented out the
DoCmd.GoToRecord , , acNewRec
statement and the purchase order comes up with the correct data. If I
could
figure out how to turn off, temporarily, acNewRec, I would have things
working ok. Any ideas?

:

Thanks for the quick response. I'm caught in a catch 22 situation -
normally
I want the purchase order entry form to independantly open ready to
accept
new data, but in the case of looking at the purchase order data from
the
bookings side of things, I want to display a record. I thought there
might
be a way to overide the default "on open" instruction.

:

You need to open the form to the specific record, just as you did in
the
earlier example. If there isn't one, the form will open empty, ready
for a
new record. If there is one, you will need a button to go to the new
record.
Delete or comment out the line:

DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I have a form where bookings are entered. Each booked order (each
record)
has
a button which opens a form that shows the purchase orders that
are
in
place
for the specific order in the bookings table. The code for the
button
is:

Private Sub Command42_Click()
On Error GoTo Err_Command42_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBkingsPO"

stLinkCriteria = "[pojobnumber]=" & "'" & Me![bkjobno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

After opening the form frmBkingsPO I can select any line item on
the
bookings form
and the frmBkingsPO form will update correctly. On the frmBkingsPO
form I
have another button for each purchase order that is listed. This
button
opens
a purchase order entry form. So far I can get the purchase order
entry
form
to open, but I don't know how to get the specific corresponding
purchase
order data to be displayed. The code for the button is:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Purchase Order Entry"

stLinkCriteria = "[ponumber]=" & Me![ponumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormPropertySettings

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

The purchase order entry form normally opens in data entry mode
and
is
ready
for the entry of new data. On open the following code is executed.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Purchase Order Entry"
DoCmd.GoToRecord , , acNewRec
End Sub

This is for data entry of new purchase orders which is normally
what
happens.

What I want to do is open the purchase order entry form and
display
the
purchase order data associated with the record selected in the
frmBkingsPO.
How can I overide the "on open" command and automatically go to
the
selected
frmBkingsPO record and display its unique data?
 
G

Guest

You are right about duplicate forms. I have done that before and it poses a
maintenance nigthmare.
I wonder if it is possible to identify from where you are making the request
to open the purchase order form. For instance - if the starting point is the
bookings form I would open as read only. If the starting point was the
switchboard I would open in edit mode and go to new record. I'm not sure what
variable would flag this option. I am after an automatic solution if I can
get it.

Arvin Meyer said:
Two forms is only very slightly easier. You will, undoubtedly, appreciate a
single form if you need to make any changes. Now you must deal with the
changes on 2 forms (and making sure that your changes are the same).
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
I understand what you are saying. I came to the conclusion that a duplicate
form would be the solution. I thought there might be a way to open the
purchase order form and overide the "on open" instruction after the form
is
open, but I think control goes to the form once it is open. Thanks for
your
help.

Arvin Meyer said:
Despite what Hollywood would have you believe, Artificial Intelligence
has
not progressed to the point of the computer intuitively knowing what you
want to do with your PO entry form. You have several choices, but all of
them will wind up branching some logic in your code.

1. You can use a dialog form and either a check box or an option group to
tell your form how to open.
2. You can have the calling form ask you how to open the PO entry form.
3. You can build 2 forms, but you still need to tell or be asked.

Code will look something like (for method 2):

If msgbox("Do you want a new PO?", vbYesNo, "POOpen type") = vbYes Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End If

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Arvin,
You are exactly right - I commented out the
DoCmd.GoToRecord , , acNewRec
statement and the purchase order comes up with the correct data. If I
could
figure out how to turn off, temporarily, acNewRec, I would have things
working ok. Any ideas?

:

Thanks for the quick response. I'm caught in a catch 22 situation -
normally
I want the purchase order entry form to independantly open ready to
accept
new data, but in the case of looking at the purchase order data from
the
bookings side of things, I want to display a record. I thought there
might
be a way to overide the default "on open" instruction.

:

You need to open the form to the specific record, just as you did in
the
earlier example. If there isn't one, the form will open empty, ready
for a
new record. If there is one, you will need a button to go to the new
record.
Delete or comment out the line:

DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I have a form where bookings are entered. Each booked order (each
record)
has
a button which opens a form that shows the purchase orders that
are
in
place
for the specific order in the bookings table. The code for the
button
is:

Private Sub Command42_Click()
On Error GoTo Err_Command42_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBkingsPO"

stLinkCriteria = "[pojobnumber]=" & "'" & Me![bkjobno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

After opening the form frmBkingsPO I can select any line item on
the
bookings form
and the frmBkingsPO form will update correctly. On the frmBkingsPO
form I
have another button for each purchase order that is listed. This
button
opens
a purchase order entry form. So far I can get the purchase order
entry
form
to open, but I don't know how to get the specific corresponding
purchase
order data to be displayed. The code for the button is:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Purchase Order Entry"

stLinkCriteria = "[ponumber]=" & Me![ponumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormPropertySettings

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

The purchase order entry form normally opens in data entry mode
and
is
ready
for the entry of new data. On open the following code is executed.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Purchase Order Entry"
DoCmd.GoToRecord , , acNewRec
End Sub

This is for data entry of new purchase orders which is normally
what
happens.

What I want to do is open the purchase order entry form and
display
the
purchase order data associated with the record selected in the
frmBkingsPO.
How can I overide the "on open" command and automatically go to
the
selected
frmBkingsPO record and display its unique data?
 
A

Arvin Meyer [MVP]

In this case, I don't think there is anything automatic. Set the form up to
work with the switchboard, because that is the easiest to attain and the
most difficult to change (did I mention, that I almost never use
switchboards, I just use a plain form with coded buttons)

Use Bookings form add the code to open it the way you want to.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
You are right about duplicate forms. I have done that before and it poses
a
maintenance nigthmare.
I wonder if it is possible to identify from where you are making the
request
to open the purchase order form. For instance - if the starting point is
the
bookings form I would open as read only. If the starting point was the
switchboard I would open in edit mode and go to new record. I'm not sure
what
variable would flag this option. I am after an automatic solution if I can
get it.

Arvin Meyer said:
Two forms is only very slightly easier. You will, undoubtedly, appreciate
a
single form if you need to make any changes. Now you must deal with the
changes on 2 forms (and making sure that your changes are the same).
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Bobk said:
I understand what you are saying. I came to the conclusion that a
duplicate
form would be the solution. I thought there might be a way to open the
purchase order form and overide the "on open" instruction after the
form
is
open, but I think control goes to the form once it is open. Thanks for
your
help.

:

Despite what Hollywood would have you believe, Artificial Intelligence
has
not progressed to the point of the computer intuitively knowing what
you
want to do with your PO entry form. You have several choices, but all
of
them will wind up branching some logic in your code.

1. You can use a dialog form and either a check box or an option group
to
tell your form how to open.
2. You can have the calling form ask you how to open the PO entry
form.
3. You can build 2 forms, but you still need to tell or be asked.

Code will look something like (for method 2):

If msgbox("Do you want a new PO?", vbYesNo, "POOpen type") = vbYes
Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End If

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Arvin,
You are exactly right - I commented out the
DoCmd.GoToRecord , , acNewRec
statement and the purchase order comes up with the correct data. If
I
could
figure out how to turn off, temporarily, acNewRec, I would have
things
working ok. Any ideas?

:

Thanks for the quick response. I'm caught in a catch 22 situation -
normally
I want the purchase order entry form to independantly open ready to
accept
new data, but in the case of looking at the purchase order data
from
the
bookings side of things, I want to display a record. I thought
there
might
be a way to overide the default "on open" instruction.

:

You need to open the form to the specific record, just as you did
in
the
earlier example. If there isn't one, the form will open empty,
ready
for a
new record. If there is one, you will need a button to go to the
new
record.
Delete or comment out the line:

DoCmd.GoToRecord , , acNewRec
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I have a form where bookings are entered. Each booked order
(each
record)
has
a button which opens a form that shows the purchase orders that
are
in
place
for the specific order in the bookings table. The code for the
button
is:

Private Sub Command42_Click()
On Error GoTo Err_Command42_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmBkingsPO"

stLinkCriteria = "[pojobnumber]=" & "'" & Me![bkjobno] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command42_Click:
Exit Sub

Err_Command42_Click:
MsgBox Err.Description
Resume Exit_Command42_Click

End Sub

After opening the form frmBkingsPO I can select any line item
on
the
bookings form
and the frmBkingsPO form will update correctly. On the
frmBkingsPO
form I
have another button for each purchase order that is listed.
This
button
opens
a purchase order entry form. So far I can get the purchase
order
entry
form
to open, but I don't know how to get the specific corresponding
purchase
order data to be displayed. The code for the button is:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Purchase Order Entry"

stLinkCriteria = "[ponumber]=" & Me![ponumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria,
acFormPropertySettings

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

The purchase order entry form normally opens in data entry mode
and
is
ready
for the entry of new data. On open the following code is
executed.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "Purchase Order Entry"
DoCmd.GoToRecord , , acNewRec
End Sub

This is for data entry of new purchase orders which is normally
what
happens.

What I want to do is open the purchase order entry form and
display
the
purchase order data associated with the record selected in the
frmBkingsPO.
How can I overide the "on open" command and automatically go to
the
selected
frmBkingsPO record and display its unique data?
 

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