I
insideout786
I have a welcome form which captures the date and cleaners form the
text box.
On enter it checks to see if the record exit in the table.
if it does it needs to open the form "CPA" to that record
else it need to first add the record to the table than open the form
"CPA" to that record.
I tried using the me.recordsetclone after opening and requerying the
form "CPA" in a module but it fails to compile when it encounters the
me.requery or me.recordsetclone.
Function setFormonOpen2()
' this query to see if the record exits in the table and returns the x
as 1 or 0
Call searchQuery
If x = 0 Then
Call AddRecordOnOpen
Me.Requery
DoCmd.OpenForm "cpa"
Call setFormOnOpen1
Else
DoCmd.OpenForm "CPA"
Call setFormOnOpen1
End If
End Function
Function AddRecordOnOpen()
Set db = CurrentDb
Set rs = db.OpenRecordset("cpa", dbOpenTable)
rs.AddNew
rs!Date = gbldate
rs!Day = Format(gbldate, "dddd")
rs!Cleaner = gblcleaner
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Function setFormOnOpen1()
Me.Requery
Set db = CurrentDb
Set rs = db.OpenRecordset("cpa", dbOpenTable)
Set rs = Me.RecordsetClone
With Me.RecordsetClone
rs.FindFirst "[date]=#" & gbldate & "# and [cleaner] = '"
& gblcleaner & "'"
If .NoMatch Then
MsgBox "No more records for this location."
Else
Me.Bookmark = .Bookmark
End If
End With
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Any Idea why???
text box.
On enter it checks to see if the record exit in the table.
if it does it needs to open the form "CPA" to that record
else it need to first add the record to the table than open the form
"CPA" to that record.
I tried using the me.recordsetclone after opening and requerying the
form "CPA" in a module but it fails to compile when it encounters the
me.requery or me.recordsetclone.
Function setFormonOpen2()
' this query to see if the record exits in the table and returns the x
as 1 or 0
Call searchQuery
If x = 0 Then
Call AddRecordOnOpen
Me.Requery
DoCmd.OpenForm "cpa"
Call setFormOnOpen1
Else
DoCmd.OpenForm "CPA"
Call setFormOnOpen1
End If
End Function
Function AddRecordOnOpen()
Set db = CurrentDb
Set rs = db.OpenRecordset("cpa", dbOpenTable)
rs.AddNew
rs!Date = gbldate
rs!Day = Format(gbldate, "dddd")
rs!Cleaner = gblcleaner
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Function setFormOnOpen1()
Me.Requery
Set db = CurrentDb
Set rs = db.OpenRecordset("cpa", dbOpenTable)
Set rs = Me.RecordsetClone
With Me.RecordsetClone
rs.FindFirst "[date]=#" & gbldate & "# and [cleaner] = '"
& gblcleaner & "'"
If .NoMatch Then
MsgBox "No more records for this location."
Else
Me.Bookmark = .Bookmark
End If
End With
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Any Idea why???