H
Hafeez Esmail
I want my code to perfrom the following algorithim.
1 Select Last_Name from TblFHStaffList
2 Search TblPredef120 with Last_Name (from
TblFHStaffList) as a criteria
3 Compare results with file C1
if different:
overwrite C1 and go to "if same"
if same:
select next name from TblFHStaffList and repeat
(as new name is selected, a new file is selected)
I need help with using the Last_Name as a criterion,
comparing to a saved file and saving the results. I don't
know which class/property/method to use when.
Attached is my code. It creates queries that ask you to
manually input a last name (when you run it). The code
doesn't compare the search to anything as yet.
Any help (even suggesting which keywords to use) would be
greatly appreciated!
Public Function MakeRpts()
Dim dbs As DAO.Database
Dim rstrec As DAO.Recordset
Dim rstname As DAO.Recordset
Dim strLastName As String
Dim qdfTemp As DAO.QueryDef
Dim qdfNew As DAO.QueryDef
Set dbs = CurrentDb()
Set rstname = dbs.OpenRecordset("TblFHStaffList",
dbOpenSnapshot)
Set rstrec = dbs.OpenRecordset("TblPredef120",
dbOpenSnapshot)
If rstname.BOF = False And rstname.EOF = False Then
rstname.MoveFirst
Do While rstname.EOF = False
strLastName = rstname!Last_Name
****Set qdfNew = dbs.CreateQueryDef(strLastName
& "Predef", "SELECT * FROM TblPredef120 WHERE Last_Name =
strLastName")****
Let qdfNew.ReturnsRecords = True
qdfNew.SQL
qdfNew.Close
Set qdfNew = Nothing
rstname.MoveNext
'(Do some stuff here)
Loop
End If
rstname.Close
Set rstname = Nothing
rstrec.Close
Set rstrec = Nothing
dbs.Close
Set dbs = Nothing
End Function
1 Select Last_Name from TblFHStaffList
2 Search TblPredef120 with Last_Name (from
TblFHStaffList) as a criteria
3 Compare results with file C1
if different:
overwrite C1 and go to "if same"
if same:
select next name from TblFHStaffList and repeat
(as new name is selected, a new file is selected)
I need help with using the Last_Name as a criterion,
comparing to a saved file and saving the results. I don't
know which class/property/method to use when.
Attached is my code. It creates queries that ask you to
manually input a last name (when you run it). The code
doesn't compare the search to anything as yet.
Any help (even suggesting which keywords to use) would be
greatly appreciated!
Public Function MakeRpts()
Dim dbs As DAO.Database
Dim rstrec As DAO.Recordset
Dim rstname As DAO.Recordset
Dim strLastName As String
Dim qdfTemp As DAO.QueryDef
Dim qdfNew As DAO.QueryDef
Set dbs = CurrentDb()
Set rstname = dbs.OpenRecordset("TblFHStaffList",
dbOpenSnapshot)
Set rstrec = dbs.OpenRecordset("TblPredef120",
dbOpenSnapshot)
If rstname.BOF = False And rstname.EOF = False Then
rstname.MoveFirst
Do While rstname.EOF = False
strLastName = rstname!Last_Name
****Set qdfNew = dbs.CreateQueryDef(strLastName
& "Predef", "SELECT * FROM TblPredef120 WHERE Last_Name =
strLastName")****
Let qdfNew.ReturnsRecords = True
qdfNew.SQL
qdfNew.Close
Set qdfNew = Nothing
rstname.MoveNext
'(Do some stuff here)
Loop
End If
rstname.Close
Set rstname = Nothing
rstrec.Close
Set rstrec = Nothing
dbs.Close
Set dbs = Nothing
End Function