Add New Records to Tables under DAO.Recordset

R

Robert Nusz @ DPS

I have a Form/Subform that I use to view records from the primary and
secondary tables that are parent/child type records.

I wanted to be able to first query the tables, looking for, locating match
to keyed records, then display via my Form/Subform with DataEntry = No
control.

I also wanted to be able to scroll forward and backward through data, and
view key information on current record as well as previous record on same
form page. This all works well using the following code for "ON CURRENT"

Private Sub Form_Current()

Me.txt_VEHICLE_CDE.SetFocus

'the following code should prevent the user from scrolling past
'BOF (Beginning-of-file) and EOF (End-of-File)

Dim rst As DAO.Recordset
Dim lngCount As Long

Set rst = Me.RecordsetClone

With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With

If Me.CurrentRecord = lngCount Then
Me.Command75_Next_Record.Enabled = False
Me.Command76_Previous_Record.Enabled = True
MsgBox "There Are No More Records To Display For This Case Number"
ElseIf Me.CurrentRecord = 1 Then
Me.Command75_Next_Record.Enabled = True
Me.Command76_Previous_Record.Enabled = False
Else
Me.Command75_Next_Record.Enabled = True
Me.Command76_Previous_Record.Enabled = True
End If
' End of Special code to prevent BOF/EOF Scrolling

Me.unbtxt_CurRecNum = Me.CurrentRecord
Me.unbtxt_TtlRecNum = lngCount

End Sub

-------------------------------

My problem lies when I need to correct a certain existing displayed on
current subform page, or when I attempt to add new records to this set of
data. When attempting to update & Save existing records I get the following
message.

"The DoMenuItem Action Was Cancelled"

My question is what type of code do I need to apply in the Before Insert
area and possibly in the After Update area to be able to modify existing
records of the DAO.Recordset or to Add more records to this existing
set of records?

I'm new to DAO.Recordset and VB code. Can someone guide me in what I have
to do in order to accomplish this task.

Thanks in advance.
 

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