Change combo by Date

coolcatkelso

Registered User.
Local time
Today, 18:36
Joined
Jan 5, 2009
Messages
279
Hiya

I have a combo box on my form called "WorkProgress" it has the following within :- Awaiting Start, Job Complete, Work in Progress"

Default value is set to Awaiting Start

I also have these filelds

JobCreationDate - (Date the Record was made)
JobStartDate - (Date the work should Start)
JobEndDate

Is there a code or something that will be like an IF statement I think

If jobStartDate = NOW()
THEN "WorkProgress.Work In Progress"?

Would that kinda work?

If the Creation date was Today, 5 Jan
And the Job STarts on the 6th Jan
Will the code automatically change to Work in Progress on the 6th? and save the user from doing it?
________
How To Roll Blunts
 
Last edited:
Code:
Private Sub Form_Current()
 If Me.jobStartDate = Date Then
  Me.WorkProgress = "Work In Progress"
 End If
End Sub
This assumes that jobStartDate is only a date, not a date and time. This is why you seldom want to use Now() in doing this kind of thing because it returns date and time, and you won't get a match. Your start date is a date and Now is date and time so your start date won't match the current date and time.
 
Hiya m8

Works a treat, I don't use Now() for that field, I just use the Date()

I change the date for todays dat and it worked perfectly, but will this still function after the date?

Obvisouly when the job is complete I would enter the Date Completed and I would intend on using the code you gave to do the same action instead it would be

Code:
Private Sub Form_Current()
 If Me.[CompletedDate] = Date Then
  Me.[WorkProgress] = "Job Complete"
 End If
End Sub

This should be ok to use?
Thanks again for the code
________
MEDICAL MARIJUANA
 
Last edited:
Obvisouly when the job is complete I would enter the Date Completed...
If you only enter the DateCompleted when the job is completed, i.e. you never enter it in advance, all you would need to do then would be to check the the field wasn't empty. Is this the case?
 
Last edited:
Hiya
Cheers for the reply

I managed to get it working

I had to do it this way,

Private Sub Form_Current()
If Me.[StartDate] = Date Then
Me.[WorkProgress] = "Work In Progress"
End If
If Me.[EndDate] = [EndDate] Then
Me.[WorkProgress] = "Job Complete"
End If

End Sub

Seems to work perfectly as ACCDB but if I compact and make as ACCDE I get an error, about a function name.. Obviously coming from the = Date

If I take that out I get no error

The error prevents me using the DBase, and access just restarts

Think it was something like

The macro or function name refers to a module that access can't find.. Something like that?
________
SOLDERING IRON VAPORIZOR
 
Last edited:
Its ok, I found a bit of code in there that should'nt have been there.. Everythings working gr8

Is that the way you would have done it for the JobCompleted? That way any date that is added in Completed will change the Combo
________
VAPIR AIR ONE 5.0 REVIEWS
 
Last edited:
It is if I was never going to enter the completed date in advance. And I've never worked a job where you could be sure of a job ending on time!

Glad you got it working!
 

Users who are viewing this thread

Back
Top Bottom