msgBox code on a button

P

Patti

I have a form with a subform that has 24 records (Hours
1 - 24) along with fields, "megawatts (MW) " and "price"
that comes from a temporary table called tblTemp. Once
the associated MW and price are entered, the user will
select the "Save" button on the main form and the data is
saved into tblSales (the tblTemp was created so that all
24 detail records would show up for each record on the
main form to eliminate having to type in the hour every
time).

I would like to add a msgBox to the "Save" button to tell
the user that they forgot to enter any MW sales for this
particular transaction. Since not all hours may have MW
associated with it, I would like to search through each
of the 24 hours until it finds a quantity listed in the
MW field. If no data is found then the error "There are
no MW's associated with this transaction". I was
thinking a Do Loop might be the answer??, but not quite
sure how to write it. Any help would be appreciated.

tia,
Patti
 
M

Michel Walsh

Hi,



Dim i As Integer
For i= 1 to 24
If IsNull(Me.Controls("MW" & i) ) then
MsgBox( "....")
Exit For
End If
Next i




Hoping it may help,
Vanderghast, Access MVP
 
M

Michel Walsh

Hi,


Note: You should not use ( ), with MsgBox, if you don't expect to
recuperate its returned result.

Vanderghast, Access MVP
 

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