Stuck in loop when checking for Me.NewRecord = True/False

I

Imran J Khan

FormA displays results of search. Double clicking on any one of the results
opens FormB to details of that record.
Eventhough I have removed the record navigation menu, the user can scroll to
a new record on FormB with the use of the mouse wheel. Since FormB is not
intended to create new records, but allows for updates to existing records, I
force the formB back to old record (the one selected using FormA) by checking
if me.NewRecord is true and then use a variable 'strSQL' that has stored the
old recordsource and reset the new record's recordsource. I use call from
FromB.Current event to run this function. This works great.
However, during development, when I open the form in Form View from design
view, it gets stuck in a loop where the recordsource keeps being set to
me.newrecord. How do I catch this?


Public Function setLoopFirstRecord(frm As Form)
Dim strSql As String
Dim intnewrec As Integer

strSql = frm.RecordSource
intnewrec = frm.NewRecord
If intnewrec = True Then
frm.RecordSource = strSql
End If

End Function


Imran J Khan
 
D

Dorian

Why not just set AllowAdditions to No for form B?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
I

Imran J Khan

Thanks for the reply Dorian.
Setting AllowAdditions to No did not work. I can still scroll to a new record.
Imran
 

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