Form help

R

radarlarry

I have a Access database containing information about toolbox inspections.
In my table I have:

Toolbox number, owning shop, date inspection due, date inspection completed,
interval, next inspection due. These are dates, except for number, owning
shop and interval.

I have a form made with these same fields. The interval in all cases is 90
days. When a user inspects a toolbox they would enter the "date inspection
completed" in the form. What I'm trying to do is to get the "next inspection
due" field to automatically add 90 days to the "date inspection completed"
field and display it in the "next inspection due" field.

I have tried using expression builder to no avail. I think it should go
something like this: DATE INSPECTION DUE + INTERVAL. I don't know the
scripts and can only use the tools available in the program itself. Oh yeah,
I also want it to update the table to the new due date.

Thanks for the help,
Larry B.
 
D

Damon Heron

'select the after update event in the properties section for your field I
am calling it [DateInspCompleted]
Private Sub [DateInspCompleted] _AfterUpdate()
Me.[yourNextInspectiondueField] = DateAdd("d", 90, DateInspCompleted)
End Sub

Damon
 
S

strive4peace

Hi Larry,

use the AfterUpdate event of your DateInspectionCompleted control...

'~~~~
if IsNull(DateInspectionCompleted_controlname) then
me.DateInspectionCompleted_controlname = null
else
me.NextInspectionDue_controlname = _
me.DateInspectionCompleted_controlname + 90
end if
'~~~~~~~

However, would it not be better to create a new record for the next
inspection date?


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
R

radarlarry1

I am radarlarry the originator of this thread. Password went byebye and had
to reregister.

Thank you for your help.

OK, I'm opening my form "CTK LIST" then right clicking in the "DATE CW '
field. I select "EVENT PROCEDURE" and the visual basic window comes up. Good
so far?

Now on the right side I have a screen with two sections, upper and lower
divided by a line. The upper part looks like this:

Command 14 and click are selected at the top. Private Sub Command14 Click()
On Error GoTo Err Command14 Click


DoCmd.Close

Exit_ Command 14_Click: Exit Sub

Err-Command 14_ Click:
MsgBox Err.Description
Resume Exit Command14 Click

End Sub

The bottom section looks like this:

Private Sub Text I5 AfterUpdate()

End Sub

Here's what I have been entering in the top section right after private sub:

[Date cw] AfterUpdateOMe.[Date Insp Due]=DateAdd("d",90, Date cw

End Sub

I have tried this in both the upper and lower sections and get this error
with [Date cw] highlighted.

COMPILE ERROR: EXPECTED IDENTIFIER

What am I doing wrong? Obviously I need a course in Visual Basic, but for the
time being I sure could use your help!!

Thanks
Larry Burdick




Damon said:
'select the after update event in the properties section for your field I
am calling it [DateInspCompleted]
Private Sub [DateInspCompleted] _AfterUpdate()
Me.[yourNextInspectiondueField] = DateAdd("d", 90, DateInspCompleted)
End Sub

Damon
I have a Access database containing information about toolbox inspections.
In my table I have:
[quoted text clipped - 21 lines]
Thanks for the help,
Larry B.
 
G

Guest

You can use code in the AfterUpdate event of the control where the user
enters the completed date. The code would be like this:

If Not IsNull(me.NameOfCompletedDateControl) then
Me.NameOfNextInspectionDateControl =
DateAdd("d",90,me.NameOfCompletedDateControl)
EndIf

Watch out for line wraping in the line that starts with
me.NameOfCompletedDateControl.

--
HTH

Mr B
email if needed to:
draccess at askdoctoraccess dot com
 
D

Damon Heron

You are getting confused with the name of the control and the source of the
control. It is probably a good idea to get in the habit of naming
textboxes, comboboxes, commandbuttons with descriptive terms so you can
understand your code more easily. Like your textbox for the DateCW field
could be called txtDateCW, for example.

Right now, the control is named TextI5, I guess. Or Text15? anyway, the
Date CW is the control source for the textbox. This is the last date the
inspection was completed, right?
Here is your after update event code:
Private Sub Text I5 AfterUpdate() ' date inspection was completed

me.[your name of the control you want updated] = DateAdd("d", 90,
me.TextI5)

End Sub

Damon

radarlarry1 said:
I am radarlarry the originator of this thread. Password went byebye and
had
to reregister.

Thank you for your help.

OK, I'm opening my form "CTK LIST" then right clicking in the "DATE CW '
field. I select "EVENT PROCEDURE" and the visual basic window comes up.
Good
so far?

Now on the right side I have a screen with two sections, upper and lower
divided by a line. The upper part looks like this:

Command 14 and click are selected at the top. Private Sub Command14
Click()
On Error GoTo Err Command14 Click


DoCmd.Close

Exit_ Command 14_Click: Exit Sub

Err-Command 14_ Click:
MsgBox Err.Description
Resume Exit Command14 Click

End Sub

The bottom section looks like this:

Private Sub Text I5 AfterUpdate()

End Sub

Here's what I have been entering in the top section right after private
sub:

[Date cw] AfterUpdateOMe.[Date Insp Due]=DateAdd("d",90, Date cw

End Sub

I have tried this in both the upper and lower sections and get this error
with [Date cw] highlighted.

COMPILE ERROR: EXPECTED IDENTIFIER

What am I doing wrong? Obviously I need a course in Visual Basic, but for
the
time being I sure could use your help!!

Thanks
Larry Burdick




Damon said:
'select the after update event in the properties section for your field I
am calling it [DateInspCompleted]
Private Sub [DateInspCompleted] _AfterUpdate()
Me.[yourNextInspectiondueField] = DateAdd("d", 90, DateInspCompleted)
End Sub

Damon
I have a Access database containing information about toolbox
inspections.
In my table I have:
[quoted text clipped - 21 lines]
Thanks for the help,
Larry B.
 

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