Update date if other field "yes"

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

I am trying to update a field with a current date if
another field is "Yes". I tried to make this happen by
using the following expression: =IIf([Duty Chrono]
=Yes,"Date()","00000000") needless to say this did not
work. How can I make this happen?

Thanks Dennis
 
I recognize this is code and is to be placed in a module
but do I place it in a new module or in the module in the
Form? Once in a module, how do I make it fire? Is there an
Event procedure I should invoke?

Thanks,

Dennis
-----Original Message-----
UPDATE tblYourTable
SET [SomeField]=Date()
WHERE [Duty Chrono] = True

--
Duane Hookom
MS Access MVP


I am trying to update a field with a current date if
another field is "Yes". I tried to make this happen by
using the following expression: =IIf([Duty Chrono]
=Yes,"Date()","00000000") needless to say this did not
work. How can I make this happen?

Thanks Dennis


.
 
This is the SQL view of a query. You can run the query from code or macro
(yuk) or database window. How do you want this to be run?

--
Duane Hookom
MS Access MVP


Dennis said:
I recognize this is code and is to be placed in a module
but do I place it in a new module or in the module in the
Form? Once in a module, how do I make it fire? Is there an
Event procedure I should invoke?

Thanks,

Dennis
-----Original Message-----
UPDATE tblYourTable
SET [SomeField]=Date()
WHERE [Duty Chrono] = True

--
Duane Hookom
MS Access MVP


I am trying to update a field with a current date if
another field is "Yes". I tried to make this happen by
using the following expression: =IIf([Duty Chrono]
=Yes,"Date()","00000000") needless to say this did not
work. How can I make this happen?

Thanks Dennis


.
 
What ever way is the cleanest giving the least
posibilities for problems later. I think code?

Thanks,

Dennis
-----Original Message-----
This is the SQL view of a query. You can run the query from code or macro
(yuk) or database window. How do you want this to be run?

--
Duane Hookom
MS Access MVP


I recognize this is code and is to be placed in a module
but do I place it in a new module or in the module in the
Form? Once in a module, how do I make it fire? Is there an
Event procedure I should invoke?

Thanks,

Dennis
-----Original Message-----
UPDATE tblYourTable
SET [SomeField]=Date()
WHERE [Duty Chrono] = True

--
Duane Hookom
MS Access MVP


I am trying to update a field with a current date if
another field is "Yes". I tried to make this happen by
using the following expression: =IIf([Duty Chrono]
=Yes,"Date()","00000000") needless to say this did not
work. How can I make this happen?

Thanks Dennis


.


.
 
The code would be:
Dim strSQL as String
strSQL = "UPDATE tblYourTable SET [SomeField]=Date() WHERE [Duty Chrono] =
True"
DoCmd.RunSQL strSQL

--
Duane Hookom
MS Access MVP


Dennis said:
What ever way is the cleanest giving the least
posibilities for problems later. I think code?

Thanks,

Dennis
-----Original Message-----
This is the SQL view of a query. You can run the query from code or macro
(yuk) or database window. How do you want this to be run?

--
Duane Hookom
MS Access MVP


I recognize this is code and is to be placed in a module
but do I place it in a new module or in the module in the
Form? Once in a module, how do I make it fire? Is there an
Event procedure I should invoke?

Thanks,

Dennis

-----Original Message-----
UPDATE tblYourTable
SET [SomeField]=Date()
WHERE [Duty Chrono] = True

--
Duane Hookom
MS Access MVP


message
I am trying to update a field with a current date if
another field is "Yes". I tried to make this happen by
using the following expression: =IIf([Duty Chrono]
=Yes,"Date()","00000000") needless to say this did not
work. How can I make this happen?

Thanks Dennis


.


.
 
Duane,
I changed the code to match my table name and field names.
The problem I have is a "Runtime error 3078 Microfost Jet
database engine cannot find the table or query
tblINMATE_RECORD. Make sure it exists and it is spelled
correctly".

This is what I have in the visual basic editor:

Private Sub Option98_Click()
Dim strSQL As String
strSQL = "UPDATE tblINMATE_RECORD SET [DUTY_CHRONO_DATE]
=Date() WHERE [Duty_Chrono] =True"
DoCmd.RunSQL strSQL



End Sub

What do you think?

Dennis

-----Original Message-----
The code would be:
Dim strSQL as String
strSQL = "UPDATE tblYourTable SET [SomeField]=Date() WHERE [Duty Chrono] =
True"
DoCmd.RunSQL strSQL

--
Duane Hookom
MS Access MVP


What ever way is the cleanest giving the least
posibilities for problems later. I think code?

Thanks,

Dennis
-----Original Message-----
This is the SQL view of a query. You can run the query from code or macro
(yuk) or database window. How do you want this to be run?

--
Duane Hookom
MS Access MVP


I recognize this is code and is to be placed in a module
but do I place it in a new module or in the module in the
Form? Once in a module, how do I make it fire? Is
there
an
Event procedure I should invoke?

Thanks,

Dennis

-----Original Message-----
UPDATE tblYourTable
SET [SomeField]=Date()
WHERE [Duty Chrono] = True

--
Duane Hookom
MS Access MVP


message
I am trying to update a field with a current date if
another field is "Yes". I tried to make this
happen
by
using the following expression: =IIf([Duty Chrono]
=Yes,"Date()","00000000") needless to say this did not
work. How can I make this happen?

Thanks Dennis


.



.


.
 
Try create a new blank query with no tables. Go to the SQL view and paste
UPDATE tblINMATE_RECORD
SET [DUTY_CHRONO_DATE] =Date()
WHERE [Duty_Chrono] =True;
View the Design view. What happens?

--
Duane Hookom
MS Access MVP


Dennis said:
Duane,
I changed the code to match my table name and field names.
The problem I have is a "Runtime error 3078 Microfost Jet
database engine cannot find the table or query
tblINMATE_RECORD. Make sure it exists and it is spelled
correctly".

This is what I have in the visual basic editor:

Private Sub Option98_Click()
Dim strSQL As String
strSQL = "UPDATE tblINMATE_RECORD SET [DUTY_CHRONO_DATE]
=Date() WHERE [Duty_Chrono] =True"
DoCmd.RunSQL strSQL



End Sub

What do you think?

Dennis

-----Original Message-----
The code would be:
Dim strSQL as String
strSQL = "UPDATE tblYourTable SET [SomeField]=Date() WHERE [Duty Chrono] =
True"
DoCmd.RunSQL strSQL

--
Duane Hookom
MS Access MVP


What ever way is the cleanest giving the least
posibilities for problems later. I think code?

Thanks,

Dennis

-----Original Message-----
This is the SQL view of a query. You can run the query
from code or macro
(yuk) or database window. How do you want this to be run?

--
Duane Hookom
MS Access MVP


message
I recognize this is code and is to be placed in a module
but do I place it in a new module or in the module in
the
Form? Once in a module, how do I make it fire? Is there
an
Event procedure I should invoke?

Thanks,

Dennis

-----Original Message-----
UPDATE tblYourTable
SET [SomeField]=Date()
WHERE [Duty Chrono] = True

--
Duane Hookom
MS Access MVP


message
I am trying to update a field with a current date if
another field is "Yes". I tried to make this happen
by
using the following expression: =IIf([Duty Chrono]
=Yes,"Date()","00000000") needless to say this did
not
work. How can I make this happen?

Thanks Dennis


.



.


.
 
Duane,
A query works nicely, thank you!

Dennis
-----Original Message-----
Try create a new blank query with no tables. Go to the SQL view and paste
UPDATE tblINMATE_RECORD
SET [DUTY_CHRONO_DATE] =Date()
WHERE [Duty_Chrono] =True;
View the Design view. What happens?

--
Duane Hookom
MS Access MVP


Duane,
I changed the code to match my table name and field names.
The problem I have is a "Runtime error 3078 Microfost Jet
database engine cannot find the table or query
tblINMATE_RECORD. Make sure it exists and it is spelled
correctly".

This is what I have in the visual basic editor:

Private Sub Option98_Click()
Dim strSQL As String
strSQL = "UPDATE tblINMATE_RECORD SET [DUTY_CHRONO_DATE]
=Date() WHERE [Duty_Chrono] =True"
DoCmd.RunSQL strSQL



End Sub

What do you think?

Dennis

-----Original Message-----
The code would be:
Dim strSQL as String
strSQL = "UPDATE tblYourTable SET [SomeField]=Date() WHERE [Duty Chrono] =
True"
DoCmd.RunSQL strSQL

--
Duane Hookom
MS Access MVP


What ever way is the cleanest giving the least
posibilities for problems later. I think code?

Thanks,

Dennis

-----Original Message-----
This is the SQL view of a query. You can run the query
from code or macro
(yuk) or database window. How do you want this to be run?

--
Duane Hookom
MS Access MVP


message
I recognize this is code and is to be placed in a module
but do I place it in a new module or in the module in
the
Form? Once in a module, how do I make it fire? Is there
an
Event procedure I should invoke?

Thanks,

Dennis

-----Original Message-----
UPDATE tblYourTable
SET [SomeField]=Date()
WHERE [Duty Chrono] = True

--
Duane Hookom
MS Access MVP


message
I am trying to update a field with a current
date
if
another field is "Yes". I tried to make this happen
by
using the following expression: =IIf([Duty Chrono]
=Yes,"Date()","00000000") needless to say this did
not
work. How can I make this happen?

Thanks Dennis


.



.



.


.
 
Back
Top