I have a form, with a hidden field, showing the current user logged on (cuser). I want another form to open, IF it matches criteria set as strsql (which works) but also where strsql1 criteria is met i.e. the current user = the person logged on. How do I add the criteria (set by strsql1) to the line DoCmd.OpenForm "f_extra_visits" etc?
i.e. the form only opens when criteria for strsql AND strsql1 are met? NOT just strsql as is happening at the moment
Thanks
Richey
Dim dbs As Database, strmsg, strsql, strsql1 As String, rst, rst1 As Recordset
Set dbs = CurrentDb
strsql1 = "SELECT * FROM Inspectors WHERE Inspectors.login = '" & CUser & "';"
Set rst1 = dbs.OpenRecordset(strsql1)
strsql = "SELECT * FROM fextra_visits_q"
Set rst = dbs.OpenRecordset(strsql)
If rst.RecordCount > 0 Then
DoCmd.OpenForm "f_extra_visits", acNormal, strsql, acFormReadOnly
Else
strmsg = "Extra visit dates? "
strmsg = MsgBox(strmsg, vbOKOnly, "No extra visit dates required"
Exit Sub
End If
i.e. the form only opens when criteria for strsql AND strsql1 are met? NOT just strsql as is happening at the moment
Thanks
Richey
Dim dbs As Database, strmsg, strsql, strsql1 As String, rst, rst1 As Recordset
Set dbs = CurrentDb
strsql1 = "SELECT * FROM Inspectors WHERE Inspectors.login = '" & CUser & "';"
Set rst1 = dbs.OpenRecordset(strsql1)
strsql = "SELECT * FROM fextra_visits_q"
Set rst = dbs.OpenRecordset(strsql)
If rst.RecordCount > 0 Then
DoCmd.OpenForm "f_extra_visits", acNormal, strsql, acFormReadOnly
Else
strmsg = "Extra visit dates? "
strmsg = MsgBox(strmsg, vbOKOnly, "No extra visit dates required"
Exit Sub
End If