Error in Adding New Record to Table

R

Robert Nusz @ DPS

I have a Form/Sub-Form that updates two tables. Parent form, updates the
primary table, sub-form updates records in the secondary table. These tables
are linked together via primary keyed fields. The primary form name is
Fr_CR_U, updates DB2 table TST_FR_CASE_RECORDS. Sub-form name is
sb-FR_OTHERS_U and it applies maintenance to DB2 Table TST_FR_CASE_OTHERS.

Form Fr_Search_By_Case is opened by user. User inputs two fields of data
that are joined to create primary key for record search against both tables,
on Enter key, Macro is executed. Primary key fields are CASE_NUM_YR and
CASE_NUM.

The form executes the following macro: FR_SEARCH_CASE which has the
following code:

SetValue [Forms]![Fr_Search_By_Case]![unbtxt_PREV_CASE_YR]
=[Forms]![Fr_Search_By_Case]![unbtxt_SEARCH_CASE_YR]

SetValue [Forms]![Fr_Search_By_Case]![unbtxt_PREV_CASE_NUM]
=[Forms]![Fr_Search_By_Case]![unbtxt_SEARCH_CASE_NUM]

Open Form Fr_CR_U Where
([TST_FR_CASE_RECORDS]![CASE_NUM_YR]=[Forms]![Fr_Search_By_Case]![unbtxt_SEARCH_CASE_YR]
And
[TST_FR_CASE_RECORDS]![CASE_NUM]=[Forms]![Fr_Search_By_Case]![unbtxt_SEARCH_CASE_NUM]) data mode=Edit window mode=Normal

Query opens form FR_CR_U and reflects only the records matching search
criteria of CASE_NUM_YR and CASE_NUM. (usually only 1 record from primary
table and possible many records from secondary table.

Form FR_CR_U allow user to scroll forward and backward with Next and
previous record command button usage, allows record changing as well to
existing records,
BUT......

Attempt to add new record and we get an errror of:
You can't go to the specified Record!

The user's uses a command button to "Add New record", this has the following
code:

Private Sub Command83_Add_New_Record_Click()
On Error GoTo Err_Command83_Add_New_Record_Click
DoCmd.GoToRecord , , acNewRec
Exit_Command83_Add_New_Record_Click:
Exit Sub

Err_Command83_Add_New_Record_Click:
MsgBox Err.Description
Resume Exit_Command83_Add_New_Record_Click
End Sub

Form clears, allows record to be entered, but user can not save record
easily. User has to click on Return to exit form in order to save the record
without getting the error, but this leaves the user only 1 chance at add
records, we may need to add more records. Can someone tell me what I'm doing
wrong....

The following code is from return command:


Private Sub Command63_Return_Main_Page_Click()
Me.Parent.SetFocus
'Me.Parent!CASE_NUM_YR_P1.SetFocus
End Sub

What do I have to do in order to be able to add multiple records to this
matching keyed secondary table file?

Thanks

Robert
 

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