Required data on subform

G

Guest

I am trying to ensure that data on contained on a subform is filled out
before moving to another record. I've tried using dlookup on the main form
to check for the key on the subform, but using cancel keeps you from being
able to move to the subform to enter the data. I've tried the dlookup code
on the subform but that allows me to move to another record if I don't enter
the data. What else can I try to keep the user from using the record
naviagation buttons to move to another record without filling out the data in
the subform? Thanks.
 
G

Guest

In the subform, use something like this in Form_BeforeUpdate

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(txtBox1) Then
MsgBox "Please complete txtBox1."
Cancel = True
End if

If IsNull(comboBox1) Then
MsgBox "Please select comboBox1."
Cancel = True
End if

End Sub

Also, just a tip - I usually disable the navigation buttons and provide a
lookup combo box and a New button to allow the user to navigate to existing
or new records - I have better control over what happens before/when the user
moves between records.

One more tip: rolling the mouse wheel will move from one record to the next,
so the tip above is not foolproof, which is why I use the aforementioned
BeforeUpdate code:)
 
G

Garret

Is there any way to disable the mouse wheel scrolling, so that the user
cannot move to different records. I think the whole system of listing
every single record is messy, and I want the user to only veiw records
that they want to veiw (that they search for).
 
G

Guest

There is a way to disable the scroll, but I don't remember. Search the forum
on it, and I think there are several posts.

The best way to display records you want is to require some sort of filter.
Have the user select the one he wants from a combo box (e.g. Customers,
listed by name), then filter the form to that one customer. That way, there
is nothing to scroll TO, outside of the records within the scope of the
filter. You could even have the combo box on a previous form so that when the
form opens, it is already filtered.

I usually filter just by putting something like this in the criteria of the
form's RecordSource: [Forms]![yourFormName]![SelectedCustomerID] where
SelectedCustomerID is the unbound combo box you use for selecting the
customer.

You may have to set AllowAdditions to False to ensure the user does not
scroll to a new record inadvertently.
 
G

Garret

I have access 2000, that is the 97 version. I tried it anyway, but I
kept getting errors while trying to open it about me not having the
authority to "convert or enable the database" even though I logged in
as an admin.
 
G

Garret

Thanks Doug =). I see that the scrolling stops for navagating records,
except when you place the cursor in the navagation text box, but that
would be gone anyway.
Just wondering, why would I have my error before? Shouldn't Access
easily be able to go from a new version to a past one, or if not, at
least give Admin the ability to log in and convert it?
 
G

Garret

Another question comes up. This mousewheel code needs to be run every
time the database is opened, or else the mousewheel will go back to ON.
He suggests putting it into a Form Load event. In my database, it
opens up without any form open, only a blank screen with menu bars
across the top, and the user can select where he/she wants to go and
what to open. I was wondering if there was a generic Startup module or
anything like that where this code could be inserted so that every time
the Database opened, the code would fire off.
If not, I suppose I would have to have some kind of "Welcome" form
where all this code could be put, but I'd rather avoid that if the
former case is true.
 

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