New Record

G

Guest

I have DB with two tables. The first table holds specifics regarding a
purchase request (purchaser, address, Phone #, etc). The second tables holds
the items being requested. The data in the two tables are linked by a
TransactionID (autonumber)
The form I put together has the data for the first table as its record
source with a subform for the various items that might be requested.

I have several buttons, each representing a different item, that update the
subform. Inserting the transactionID and whatever item is being requested.
Like this:
Private Sub RequestLabResults_Click()
Forms![frmROIRequest]![fsubItemRequested]![TransactionID] =
Me.TransactionNumber
Forms![frmROIRequest]![fsubItemRequested]![ItemRequested] = "Lab Results"
End Sub

My problem is, after the initial button is pushed and the subform updates,
it does not go to the next, blank record. If I press another button it
updates the original record. Can I add code to the end of my click events
that will send the focus to the next, new record? (like carriage return on a
type writer)

TIA

Antonio
 
P

pietlinden

I have DB with two tables. The first table holds specifics regarding a
purchase request (purchaser, address, Phone #, etc). The second tables holds
the items being requested. The data in the two tables are linked by a
TransactionID (autonumber)
The form I put together has the data for the first table as its record
source with a subform for the various items that might be requested.

I have several buttons, each representing a different item, that update the
subform. Inserting the transactionID and whatever item is being requested.
Like this:
Private Sub RequestLabResults_Click()
Forms![frmROIRequest]![fsubItemRequested]![TransactionID] =
Me.TransactionNumber
Forms![frmROIRequest]![fsubItemRequested]![ItemRequested] = "Lab Results"
End Sub

My problem is, after the initial button is pushed and the subform updates,
it does not go to the next, blank record. If I press another button it
updates the original record. Can I add code to the end of my click events
that will send the focus to the next, new record? (like carriage return on a
type writer)

TIA

Antonio

GoToRecord is your friend
 
G

Guest

Thank you for the reply.

I get the following error message when I tried the GoTo Record:
"An expression you entered is the wrong data type for one of the arguments".

This is the code I attached to the command button that is doing the updating.

Private Sub RequestXRAY_Click()
Forms![frmROIRequest]![fsubItemRequested]![TransactionID] =
Me.TransactionNumber
Forms![frmROIRequest]![fsubItemRequested]![ItemRequested] = "XRAY"
DoCmd.GoToRecord acDataForm, Forms![frmROIRequest]![fsubItemRequested],
acNewRec

End Sub

Assuming I can get the code right, should I be attaching it to the click
event of the button or on the After Update event on the sub form?

TIA

Antonio

I have DB with two tables. The first table holds specifics regarding a
purchase request (purchaser, address, Phone #, etc). The second tables holds
the items being requested. The data in the two tables are linked by a
TransactionID (autonumber)
The form I put together has the data for the first table as its record
source with a subform for the various items that might be requested.

I have several buttons, each representing a different item, that update the
subform. Inserting the transactionID and whatever item is being requested.
Like this:
Private Sub RequestLabResults_Click()
Forms![frmROIRequest]![fsubItemRequested]![TransactionID] =
Me.TransactionNumber
Forms![frmROIRequest]![fsubItemRequested]![ItemRequested] = "Lab Results"
End Sub

My problem is, after the initial button is pushed and the subform updates,
it does not go to the next, blank record. If I press another button it
updates the original record. Can I add code to the end of my click events
that will send the focus to the next, new record? (like carriage return on a
type writer)

TIA

Antonio

GoToRecord is your friend
 
G

Guest

Looks like you have two different data types. My guess would be
Forms![frmROIRequest]![fsubItemRequested]![TransactionID] is Text or Long
Integer and Me.TransactionNumber is something else.

A great way to troubleshoot your code is in the code window, click the left
column which will put a red dot (pause) then when you run the code, it will
switch to the code window and you can step through each line at a time using
F8. You can then see which line produces the error.

Hope this helps.
--
Thanks,

Jason W. Martin
TRIa Technology


Antonio said:
Thank you for the reply.

I get the following error message when I tried the GoTo Record:
"An expression you entered is the wrong data type for one of the arguments".

This is the code I attached to the command button that is doing the updating.

Private Sub RequestXRAY_Click()
Forms![frmROIRequest]![fsubItemRequested]![TransactionID] =
Me.TransactionNumber
Forms![frmROIRequest]![fsubItemRequested]![ItemRequested] = "XRAY"
DoCmd.GoToRecord acDataForm, Forms![frmROIRequest]![fsubItemRequested],
acNewRec

End Sub

Assuming I can get the code right, should I be attaching it to the click
event of the button or on the After Update event on the sub form?

TIA

Antonio

I have DB with two tables. The first table holds specifics regarding a
purchase request (purchaser, address, Phone #, etc). The second tables holds
the items being requested. The data in the two tables are linked by a
TransactionID (autonumber)
The form I put together has the data for the first table as its record
source with a subform for the various items that might be requested.

I have several buttons, each representing a different item, that update the
subform. Inserting the transactionID and whatever item is being requested.
Like this:
Private Sub RequestLabResults_Click()
Forms![frmROIRequest]![fsubItemRequested]![TransactionID] =
Me.TransactionNumber
Forms![frmROIRequest]![fsubItemRequested]![ItemRequested] = "Lab Results"
End Sub

My problem is, after the initial button is pushed and the subform updates,
it does not go to the next, blank record. If I press another button it
updates the original record. Can I add code to the end of my click events
that will send the focus to the next, new record? (like carriage return on a
type writer)

TIA

Antonio

GoToRecord is your friend
 

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