C
Craig M. Bobchin
Hi All,
I've got a form/subform combo that I'm trying to create a button that
will let me add a recordto the table. Unfortunately it does not work. I
get an error message saying "you can't go to the specified record."
Below is the code used in the Add Button click event:
Private Sub cmdAdd_Click()
On Error GoTo Err_cmdAdd_Click
Me.cboResourceID.Enabled = True
Me.cboWeekID.Enabled = True
Me.cboResourceID.Locked = False
Me.cboResourceID.Value = Forms!frmMainMenu.ResourceID
Me.cboResourceID.BackStyle = 1
Me.cboWeekID.BackStyle = 1
Me.cboWeekID.Locked = False
Me.cboSelect.Visible = False
Me.fsubTimeCards.Enabled = True
Me.lblInfo.Visible = False
Me.cboWeekID.SetFocus
DoCmd.GoToRecord , , acNewRec
Exit_cmdAdd_Click:
Exit Sub
Err_cmdAdd_Click:
MsgBox Err.Description
Resume Exit_cmdAdd_Click
End Sub
The table I'm trying to add the record to is comprised of two fields
(both part of the PK) It is a bound form, as is the subform. I've tried
putting the DoCmd line both at the front and at the end of the block of
code and had no luck.
The resourceID and WeekID fields are both comboboxes on the form, I
populate the resourceID with the user's ID from the main menu, and then
want the user to pick a Week. This will then ensure both parts of the
key are there before the record is created. After that they should be
able to go to the subform and enter data.
I've even tried putting the DoCmd.GoToRecord , , acNewRec as part of the
exit code of the weekID combo box since it only after the users selects
a week that the key is complete. All to no avail.
Can anyone help me sort this out? It is Urgent.
Thanks
I've got a form/subform combo that I'm trying to create a button that
will let me add a recordto the table. Unfortunately it does not work. I
get an error message saying "you can't go to the specified record."
Below is the code used in the Add Button click event:
Private Sub cmdAdd_Click()
On Error GoTo Err_cmdAdd_Click
Me.cboResourceID.Enabled = True
Me.cboWeekID.Enabled = True
Me.cboResourceID.Locked = False
Me.cboResourceID.Value = Forms!frmMainMenu.ResourceID
Me.cboResourceID.BackStyle = 1
Me.cboWeekID.BackStyle = 1
Me.cboWeekID.Locked = False
Me.cboSelect.Visible = False
Me.fsubTimeCards.Enabled = True
Me.lblInfo.Visible = False
Me.cboWeekID.SetFocus
DoCmd.GoToRecord , , acNewRec
Exit_cmdAdd_Click:
Exit Sub
Err_cmdAdd_Click:
MsgBox Err.Description
Resume Exit_cmdAdd_Click
End Sub
The table I'm trying to add the record to is comprised of two fields
(both part of the PK) It is a bound form, as is the subform. I've tried
putting the DoCmd line both at the front and at the end of the block of
code and had no luck.
The resourceID and WeekID fields are both comboboxes on the form, I
populate the resourceID with the user's ID from the main menu, and then
want the user to pick a Week. This will then ensure both parts of the
key are there before the record is created. After that they should be
able to go to the subform and enter data.
I've even tried putting the DoCmd.GoToRecord , , acNewRec as part of the
exit code of the weekID combo box since it only after the users selects
a week that the key is complete. All to no avail.
Can anyone help me sort this out? It is Urgent.
Thanks