C
charleswoods via AccessMonster.com
Hello and Thanks in Advance!
I am new to VBA and need some advice. I am building a datawarehouse and I
have created a Macro that I can run periodically to append my summarized
records to. If I don't remember the last date, I could easily append the same
record again & again. I want to automate this process so that every night at
2am my program kicks off and loads yesterday's records.
I have started by trying to build a check based upon my system date. Below is
my beginning:
Public Sub LastRecordCheck()
Dim db As DAO.Database
Dim rstd As DAO.Recordset
Dim lastdate As Date
Set db = CurrentDb
Set rstd = db.OpenRecordset("SELECT Format(tblData_10Patient.ARRVDATE,
'mm/dd/yyyy') AS RecordExists "& _
"FROM tblData_10Patient GROUP BY Format(tblData_10Patient.ARRVDATE,
'mm/dd/yyyy') "& _
"HAVING (((Format(tblData_10Patient.ARRVDATE,'mm/dd/yyyy'))=Format(Now(),
'mm/dd/yyyy')));"
lastdate = rstd.Fields("RecordExists")
If lastdate Is Null Then End
Else
MsgBox "The date entered, " & lastdate & " already exists in the records."
MsgBox "Please enter a different date."
rstd.Close
End
I keep getting the following error : Compile Error : Expected: List separator
or )
Any Advice?
Charles Woods
I am new to VBA and need some advice. I am building a datawarehouse and I
have created a Macro that I can run periodically to append my summarized
records to. If I don't remember the last date, I could easily append the same
record again & again. I want to automate this process so that every night at
2am my program kicks off and loads yesterday's records.
I have started by trying to build a check based upon my system date. Below is
my beginning:
Public Sub LastRecordCheck()
Dim db As DAO.Database
Dim rstd As DAO.Recordset
Dim lastdate As Date
Set db = CurrentDb
Set rstd = db.OpenRecordset("SELECT Format(tblData_10Patient.ARRVDATE,
'mm/dd/yyyy') AS RecordExists "& _
"FROM tblData_10Patient GROUP BY Format(tblData_10Patient.ARRVDATE,
'mm/dd/yyyy') "& _
"HAVING (((Format(tblData_10Patient.ARRVDATE,'mm/dd/yyyy'))=Format(Now(),
'mm/dd/yyyy')));"
lastdate = rstd.Fields("RecordExists")
If lastdate Is Null Then End
Else
MsgBox "The date entered, " & lastdate & " already exists in the records."
MsgBox "Please enter a different date."
rstd.Close
End
I keep getting the following error : Compile Error : Expected: List separator
or )
Any Advice?
Charles Woods