No New Records

G

Guest

I have a form, based on a query.

The query filters the zones based on another form. There is a subform,
based on another query that shows vendors within each zone. I tried to set
it up so neither form can add records to any table. I set allow additions,
deletions to no, and got rid of the record selectors and navigation buttons
for both controls. I then set up command buttons on the main form to
navigate through the records on the main form, so there should be no way for
the user to accidentally create a new zone by hitting the wrong button.

Unfortunately, you can still use the "next record" command button to cycle
through to a new, blank record. How can I make this stop?
aaron
 
S

Steve Schapel

Aaron,

At the top of the form's module, where it says:
Option Compare Database
Option Explicit
.... define a variable to hold the number of records for the form, e.g...
Dim HowManyRecords As Long

In the form's Load event, put code like this...
Dim rst As DAO.recordSet
Set rst = Me.RecordsetClone
rst.MoveLast
HowManyRecords = rst.RecordCount
Set rst = Nothing

In the Current event of the form, put a line of code like this...
If Me.CurrentRecord = HowManyRecords Then
Me.PreviousButton.SetFocus
Me.NextButton.Enabled = False
Else
Me.NextButton.Enabled = True
End If
 
G

George Nicholson

One approach: In your "OnCurrent" event, if MyForm.NewRecord is True, go
back a record (setting Dirty to False, if necessary, so any Default values
that have been filled in don't trigger a record update/save)
 

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