Mr.B

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

you responded to my question about setting uop an event to alert users of
needing to update a record with this:

You can place code in the "OnCurrent" event of your form that will check the
value of the date and provide information to the user.

The code would be something like:

If Not IsNull(Me.NameOfDateField) then
If me.NameOfDateField < Date then
Msgbox "The Biology exam date is past due!"
End IF
End If

By using the acutual name of your Date control in place of the
"NameOfDateField" in both places above, every time a record is displayed in
your form, this code will check to see if the date in the Bilology Date field
is less than todays date. If it is, the message box will be displayed.

If there is no value in the Bilology Date field or the value in the Bilology
Date field is equal to or greater than todays date, then no message will be
presented.

It sounds like the perfect thing but I'm not sure how to achevie this. I
don't know that much about access and I am trying to get this project done.
If you could break down the steps a little simpler I would be in your debt.
If there is anyone else who could break this down in a how-to step by step
guide including the exact code I'd be overjoyed, thanks.
 
Hi

I have not read the original post but I "think" the answer may be telling
you how to let the user see a popup message if your date field is before
today.

Mr B gave you this answer OnCurrent
If Not IsNull(Me.NameOfDateField) then
If me.NameOfDateField < Date then
Msgbox "The Biology exam date is past due!"
End IF
End If

To use this
Open your form in design view
Right click the darker grey area (outside the detail)
Select the properties option from the box the appears
A new option box will appear
Go the Event column
Select the OnCurrent row
Click the build option (... at the end of the row)
Select Code
You will see this

Private Sub Form_Current()

End Sub

Insert the code Mr B gave you (cut and paste) it between the 2 line of code
so that you end up with this


Private Sub Form_Current()
If Not IsNull(Me.NameOfDateField) then
If me.NameOfDateField < Date then
Msgbox "The Biology exam date is past due!"
End IF
End If
End Sub

Next (important)
Click save and go back to your form (click the Red X in the top right of the
screen)
If the propoerties box is not open - opne it as above.
Select your date field
Go to the "other" column in the properties box and on the top row look at
the "name"
You must insert this name into the code you have just made in place of
NameOfDateField.
So if your field is called txtDate (or whatever) your code would now look
like this

Private Sub Form_Current()
If Not IsNull(Me.txtDate) then
If me.NameOfDateField < Date then
Msgbox "The Biology exam date is past due!"
End IF
End If
End Sub

Note that txtDate has been inserted. You must put the Name of your data
field into the code.

Click save and use the form.

Hope this helps
 
kawaii1,

Sorry for not responding sooner, I had jury duty and was not available.

Wayne-I-M got it mostly correct, except:

After inserting the code that I posted in the OnCurrent event of your form,
you will need to substitute the actual name of the control in your form that
has the date field as its data source.

Each control on your form has a name. If your form is a data bound form (if
it is linked to data directly from a table or a query as its record source)
then each of your controls on your form will have a field from the data
source as its source field.

Use the name of the control, not the field name in the code.

The code that I posted was just a short version of what might actually be
needed to complete your project and make it do what you want.

Please post back if you need more assistance.

I and otheres will be very happy to try to help.
 

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

Back
Top