473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Update contents of text field based on calculated dates

Hi,

I have a continuous form that provides a listing of various
instruments that are
serviced on a monthly to annual basis, with general info about the
instrument, last and next service dates, etc.

What I am trying to do is create an On Open event procedure that will
identify all instruments that are listed with a string of either "Past
Due" or "Schedule Vendor" based on whether each of their respective
'Due' dates have already transpired or not from the current month, all
in one shot.

The code I initially created for this was as follows:
Private Sub Form_Open()
Dim myDate, myDue
myDate = DateSerial(Year(me.ListDate), Month(Me.ListDate), 1)
myDue = Me.NextServiceDate
If Me.Due < mydate then
Me.Status="Past Due"
Elseif Me.Due >= mydate then
Me.Status="Schedule Vendor"
End if

End Sub

This of course only updates the first 'Status' field on the list but
not the rest. I know I probably need to code this under a Do...Loop
or For Each...Next statement, but I simply cannot figure out the
right way to do this.
Any help would really be appreciated.
Regards,
Ruben

May 20 '07 #1
4 1840
On 19 May 2007 20:14:31 -0700, Ruben <ru*********@gmail.comwrote:

You can do what you're suggesting: see RecordsetClone in the Help
file.
I would rather run an Update query against the underlying table, and
then refresh the form.

-Tom.

>Hi,

I have a continuous form that provides a listing of various
instruments that are
serviced on a monthly to annual basis, with general info about the
instrument, last and next service dates, etc.

What I am trying to do is create an On Open event procedure that will
identify all instruments that are listed with a string of either "Past
Due" or "Schedule Vendor" based on whether each of their respective
'Due' dates have already transpired or not from the current month, all
in one shot.

The code I initially created for this was as follows:
Private Sub Form_Open()
Dim myDate, myDue
myDate = DateSerial(Year(me.ListDate), Month(Me.ListDate), 1)
myDue = Me.NextServiceDate
If Me.Due < mydate then
Me.Status="Past Due"
Elseif Me.Due >= mydate then
Me.Status="Schedule Vendor"
End if

End Sub

This of course only updates the first 'Status' field on the list but
not the rest. I know I probably need to code this under a Do...Loop
or For Each...Next statement, but I simply cannot figure out the
right way to do this.
Any help would really be appreciated.
Regards,
Ruben
May 20 '07 #2
On May 19, 8:50 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 19 May 2007 20:14:31 -0700, Ruben <rubenfmu...@gmail.comwrote:

You can do what you're suggesting: see RecordsetClone in the Help
file.
I would rather run an Update query against the underlying table, and
then refresh the form.

-Tom.
Hi,
I have a continuous form that provides a listing of various
instruments that are
serviced on a monthly to annual basis, with general info about the
instrument, last and next service dates, etc.
What I am trying to do is create an On Open event procedure that will
identify all instruments that are listed with a string of either "Past
Due" or "Schedule Vendor" based on whether each of their respective
'Due' dates have already transpired or not from the current month, all
in one shot.
The code I initially created for this was as follows:
Private Sub Form_Open()
Dim myDate, myDue
myDate = DateSerial(Year(me.ListDate), Month(Me.ListDate), 1)
myDue = Me.NextServiceDate
If Me.Due < mydate then
Me.Status="Past Due"
Elseif Me.Due >= mydate then
Me.Status="Schedule Vendor"
End if
End Sub
This of course only updates the first 'Status' field on the list but
not the rest. I know I probably need to code this under a Do...Loop
or For Each...Next statement, but I simply cannot figure out the
right way to do this.
Any help would really be appreciated.
Regards,
Ruben- Hide quoted text -

- Show quoted text -
Thanks for your help Tom, this is an option I hadn't even considered
and appears to work quite well! For my own information, if wanted to
achieve the same thing using VB code, what script structure could I
use?

-Ruben

May 20 '07 #3
On 19 May 2007 23:35:37 -0700, Ruben <ru*********@gmail.comwrote:

Dim myDate, myDue
with me.Recordsetclone
.MoveFirst
while not .eof

myDate = DateSerial(Year(me.ListDate), Month(Me.ListDate), 1)
myDue = Me.NextServiceDate
If Me.Due < mydate then
!Status="Past Due"
Elseif Me.Due >= mydate then
!Status="Schedule Vendor"
End if

.MoveNext
wend
end with

-Tom.

>On May 19, 8:50 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
>On 19 May 2007 20:14:31 -0700, Ruben <rubenfmu...@gmail.comwrote:

You can do what you're suggesting: see RecordsetClone in the Help
file.
I would rather run an Update query against the underlying table, and
then refresh the form.

-Tom.
>Hi,
>I have a continuous form that provides a listing of various
instruments that are
serviced on a monthly to annual basis, with general info about the
instrument, last and next service dates, etc.
>What I am trying to do is create an On Open event procedure that will
identify all instruments that are listed with a string of either "Past
Due" or "Schedule Vendor" based on whether each of their respective
'Due' dates have already transpired or not from the current month, all
in one shot.
>The code I initially created for this was as follows:
>Private Sub Form_Open()
Dim myDate, myDue
>myDate = DateSerial(Year(me.ListDate), Month(Me.ListDate), 1)
myDue = Me.NextServiceDate
>If Me.Due < mydate then
Me.Status="Past Due"
Elseif Me.Due >= mydate then
Me.Status="Schedule Vendor"
End if
>End Sub
>This of course only updates the first 'Status' field on the list but
not the rest. I know I probably need to code this under a Do...Loop
or For Each...Next statement, but I simply cannot figure out the
right way to do this.
>Any help would really be appreciated.
>Regards,
Ruben- Hide quoted text -

- Show quoted text -

Thanks for your help Tom, this is an option I hadn't even considered
and appears to work quite well! For my own information, if wanted to
achieve the same thing using VB code, what script structure could I
use?

-Ruben
May 20 '07 #4
On May 20, 9:54 am, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 19 May 2007 23:35:37 -0700, Ruben <rubenfmu...@gmail.comwrote:

Dim myDate, myDue
with me.Recordsetclone
.MoveFirst
while not .eof

myDate = DateSerial(Year(me.ListDate), Month(Me.ListDate), 1)
myDue = Me.NextServiceDate
If Me.Due < mydate then
!Status="Past Due"
Elseif Me.Due >= mydate then
!Status="Schedule Vendor"
End if

.MoveNext
wend
end with

-Tom.
On May 19, 8:50 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On 19 May 2007 20:14:31 -0700, Ruben <rubenfmu...@gmail.comwrote:
You can do what you're suggesting: see RecordsetClone in the Help
file.
I would rather run an Update query against the underlying table, and
then refresh the form.
-Tom.
Hi,
I have a continuous form that provides a listing of various
instruments that are
serviced on a monthly to annual basis, with general info about the
instrument, last and next service dates, etc.
What I am trying to do is create an On Open event procedure that will
identify all instruments that are listed with a string of either "Past
Due" or "Schedule Vendor" based on whether each of their respective
'Due' dates have already transpired or not from the current month, all
in one shot.
The code I initially created for this was as follows:
Private Sub Form_Open()
Dim myDate, myDue
myDate = DateSerial(Year(me.ListDate), Month(Me.ListDate), 1)
myDue = Me.NextServiceDate
If Me.Due < mydate then
Me.Status="Past Due"
Elseif Me.Due >= mydate then
Me.Status="Schedule Vendor"
End if
End Sub
This of course only updates the first 'Status' field on the list but
not the rest. I know I probably need to code this under a Do...Loop
or For Each...Next statement, but I simply cannot figure out the
right way to do this.
Any help would really be appreciated.
Regards,
Ruben- Hide quoted text -
- Show quoted text -
Thanks for your help Tom, this is an option I hadn't even considered
and appears to work quite well! For my own information, if wanted to
achieve the same thing using VB code, what script structure could I
use?
-Ruben- Hide quoted text -

- Show quoted text -
Tom,

I could not get the line of code you proposed to work. I corrected
'Me.Due' to 'myDue' and made sure everything else was okay but it
still did not work. Even so, I will follow your advise and use an
Update query instead.

Again, your time, effort and assistance on this matter was very much
appreciated.

Regards,
Ruben

May 20 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Baker | last post by:
Hi: Hi: I have a form which is based on a query, and is being used to update a table. It all works well, except for one thing. I have a number of unbound calculation fields (total value,...
2
by: Joseph Markovich | last post by:
I'm having some trouble with VB in Access 2000. I have a form that the user enters in just one number (in this case, it's a base salary) and then the program is going to do a bunch of math (which...
2
by: Norbert Lieckfeldt | last post by:
I am setting up a database for a friend who's an Optician, using MS Access 2002. All seems to be working well, but I have hit a snag. There's a calculated field both in a form and a query which...
1
by: Manish | last post by:
Hello Everyone I am having weird problem in my datagrid bounded to datatable. My datatable is populated from SQLServer database. DataGrid has Calculated column Week% and Calculated record, SPLH....
3
by: rdc2732 | last post by:
I have a form with 10 numeric input fields (envision two rows and five columns). There is a column at the right for a total of each of the fields on each row. There is also a row with a...
1
by: jburris | last post by:
I am completely new to VBA. I am trying to update a yes/no box in a subform based on a value that I call from the main form into the subform. Below is the if /then statement i am using: If...
6
by: KevinPreston | last post by:
Hello everyone, this is my first post so apologies if i dont get it right first time, i am a self taught Access user, i am stuck on something i am trying to do, briefly i have 2 tables, one for...
2
by: dympna | last post by:
Hi can anyone suggest a fix for this... as I am a novice in access. I have created a training table with the following fields Employee Name - joe Training Received - Fork lift Date Received...
2
by: DeanL | last post by:
Hi guys, I'm using a subform to display a list of values from a single table. The form is showing the values in "continuous forms" view and there will only ever be two different values for the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.