C
chickenfriedsteak
Is there any to run (but not display) a query when you make a change
to a form?
I've got a system now that is tracking backup jobs in our enterprise.
What I've done is first setup a query that will look at the date in a
table and return a numeric value for day of the week to another field
on the table (this field doesn't show on the form). Then I've got
another query that reads what that numeric day of the week code is and
compares it to a table that lists all the days of the week, and
returns that name of the day to a third field on the table (this field
shows up on the form).
Basically what I want to have happen is when I select a date on the
form, I want the first query (figure out which numeric day of the week
corresponds to that date) to run, then the second query to run (figure
out which named day of the week corresponds to that numeric value).
Here's a snippet of code I've been struggling with that I found online
- the error is "Method or data member not found" on .RunQuery. I'm
using Access 2007, so I can only assume the website I found this on
was referencing a previous version of Access.
Is there anything analogous to this command in 2007?
Private Sub CurDate_AfterUpdate()
'Turns off the Access warning messages
DoCmd.SetWarnings False
'Converts the dd/dd/dddd date to a numeric day of the
week
DoCmd.RunQuery "qryGetNumericDayofWeek"
'Does a LOOKUP to convert the numeric day to named day
DoCmd.RunQuery "qryGetVerbalDayofWeek"
'Turns the Access warning messages back on
DoCmd.SetWarnings True
End Sub
Here's what I have in my queries:
qryGetNumericDayofWeek
UPDATE tblLaptopsBackups SET tblLaptopsBackups.NumofWeek = Weekday
([CurDate],1);
qryGetVerbalDayofWeek
UPDATE tblLOOKUPDaysoftheWeek, tblLaptopsBackups SET
tblLaptopsBackups.DayofWeek = [tblLOOKUPDaysoftheWeek].[DayoftheWeek]
WHERE (((tblLaptopsBackups.NumofWeek)=[tblLOOKUPDaysoftheWeek].
[DayNum]));
The form uses the field tblLaptopsBackups.DayofWeek as the field with
the spelled out day of the week on the form; tblLOOKUPDaysoftheWeek is
just a listing of all the numeric values for the Weekday() function
and what they equal in spelled out days.
to a form?
I've got a system now that is tracking backup jobs in our enterprise.
What I've done is first setup a query that will look at the date in a
table and return a numeric value for day of the week to another field
on the table (this field doesn't show on the form). Then I've got
another query that reads what that numeric day of the week code is and
compares it to a table that lists all the days of the week, and
returns that name of the day to a third field on the table (this field
shows up on the form).
Basically what I want to have happen is when I select a date on the
form, I want the first query (figure out which numeric day of the week
corresponds to that date) to run, then the second query to run (figure
out which named day of the week corresponds to that numeric value).
Here's a snippet of code I've been struggling with that I found online
- the error is "Method or data member not found" on .RunQuery. I'm
using Access 2007, so I can only assume the website I found this on
was referencing a previous version of Access.
Is there anything analogous to this command in 2007?
Private Sub CurDate_AfterUpdate()
'Turns off the Access warning messages
DoCmd.SetWarnings False
'Converts the dd/dd/dddd date to a numeric day of the
week
DoCmd.RunQuery "qryGetNumericDayofWeek"
'Does a LOOKUP to convert the numeric day to named day
DoCmd.RunQuery "qryGetVerbalDayofWeek"
'Turns the Access warning messages back on
DoCmd.SetWarnings True
End Sub
Here's what I have in my queries:
qryGetNumericDayofWeek
UPDATE tblLaptopsBackups SET tblLaptopsBackups.NumofWeek = Weekday
([CurDate],1);
qryGetVerbalDayofWeek
UPDATE tblLOOKUPDaysoftheWeek, tblLaptopsBackups SET
tblLaptopsBackups.DayofWeek = [tblLOOKUPDaysoftheWeek].[DayoftheWeek]
WHERE (((tblLaptopsBackups.NumofWeek)=[tblLOOKUPDaysoftheWeek].
[DayNum]));
The form uses the field tblLaptopsBackups.DayofWeek as the field with
the spelled out day of the week on the form; tblLOOKUPDaysoftheWeek is
just a listing of all the numeric values for the Weekday() function
and what they equal in spelled out days.