D
David Wilch
This is driving me crazy.
First, I'm a novice at access and VBA.
I'm using Access 2003.
I have a form "Athlete_Registration"
This form works great. I can edit old athletes from the table "Athlete"
using a listbox to find them quickly or add a new athlete.
I have subform "Registration_Form".
This subform is linked to the form "Athlete_Registration" with the
Athlete_Number (primary key).
The name and number display correctly on the subform correctly.
Next to the name and noumber, I have a list box "Event_List" of events from
a table "Events".
This appears to display correctly.
Odd note: if the athlete is an old customer, his last event is highlighted
and it also displays the number of his events at the bottom of this subform.
This is not a problem, just a possible clue.
What I'm trying to do:
when I click on an event in the listbox "Events_List", I want the
Athlete_Number and Event_Number to be entered as a new record into the
table "Registration" (auto-numbered).
Code under On Click of the list box:
Private Sub Event_List_Click()
On Error GoTo Err_List_Click
DoCmd.GoToRecord , , acNewRec
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Exit_List_Click:
Exit Sub
Err_List_Click:
MsgBox Err.Description
Resume Exit_List_Click
End Sub
Here's what happens:
If there is no previous record of the Athlete_Number in "Registration", it
works fine.
If there is a history, then it edits (does not add new) one of the athletes
events.
I noticed that the record number at the bottom of the sub-form increases,
but nothing was recorded in that location.
I thought the problem might have been with setfocus, so I tried this:
Me.Registration_Form.SetFocus
DoCmd.GoToRecord , , acNewRec
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
....And I get Compile Error: Method or data member not found.
One thing that does work, I added a button for new_record to the subform and
I have to click it (or the asterik at the bottom of the Form) prior to
clicking in the listbox and it works perfectly.
But I need to intergrate the new_record action into the On_Click procedure
to reduce data entry errors.
TIA,
David
First, I'm a novice at access and VBA.
I'm using Access 2003.
I have a form "Athlete_Registration"
This form works great. I can edit old athletes from the table "Athlete"
using a listbox to find them quickly or add a new athlete.
I have subform "Registration_Form".
This subform is linked to the form "Athlete_Registration" with the
Athlete_Number (primary key).
The name and number display correctly on the subform correctly.
Next to the name and noumber, I have a list box "Event_List" of events from
a table "Events".
This appears to display correctly.
Odd note: if the athlete is an old customer, his last event is highlighted
and it also displays the number of his events at the bottom of this subform.
This is not a problem, just a possible clue.
What I'm trying to do:
when I click on an event in the listbox "Events_List", I want the
Athlete_Number and Event_Number to be entered as a new record into the
table "Registration" (auto-numbered).
Code under On Click of the list box:
Private Sub Event_List_Click()
On Error GoTo Err_List_Click
DoCmd.GoToRecord , , acNewRec
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Exit_List_Click:
Exit Sub
Err_List_Click:
MsgBox Err.Description
Resume Exit_List_Click
End Sub
Here's what happens:
If there is no previous record of the Athlete_Number in "Registration", it
works fine.
If there is a history, then it edits (does not add new) one of the athletes
events.
I noticed that the record number at the bottom of the sub-form increases,
but nothing was recorded in that location.
I thought the problem might have been with setfocus, so I tried this:
Me.Registration_Form.SetFocus
DoCmd.GoToRecord , , acNewRec
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
....And I get Compile Error: Method or data member not found.
One thing that does work, I added a button for new_record to the subform and
I have to click it (or the asterik at the bottom of the Form) prior to
clicking in the listbox and it works perfectly.
But I need to intergrate the new_record action into the On_Click procedure
to reduce data entry errors.
TIA,
David