I have used the following code (thanks to a tek-tips contributor) very successfuly, but now wish to enable it for multi-users according to the value receiptlocationID:
I thought adding the latter field to the SQL would enable one to find the last record by ReceiptID and by receiptlocationID. Am I barking up the wrong tree or am I just barking? Any assistance would be greatfully received.
Ted.
Code:
Private Sub Form_Current()
Dim db As DAO.Database, rst As DAO.Recordset, SQL As String
If Me.NewRecord Then
Set db = CurrentDb
SQL = "SELECT TOP 1 [ReceiptID], receiptlocationID, Book, Receipt, ReceiptDate, ProjDeptID, LocationSuffixID, AccountID " & _
"FROM Receipts " & _
"ORDER BY [ReceiptID],[receiptlocationID]DESC;"
Set rst = db.OpenRecordset(SQL, dbOpenDynaset)
If Not (rst.BOF Or rst.EOF) Then
Me!Combo172 = Nz(rst!receiptlocationID, "")
Me!Book.DefaultValue = Nz(rst!Book, "")
Me!Receipt.DefaultValue = Nz(rst!Receipt + 1, "")
Me!ReceiptDate.DefaultValue = "#" & Format(Nz(rst!ReceiptDate, Date), "yyyy-mm-dd") & "#"
Me!ProjDeptID.DefaultValue = Nz(rst!ProjDeptID, "")
Me!LocationSuffixID.DefaultValue = Nz(rst!LocationSuffixID, "")
Me!AccountID.DefaultValue = Nz(rst!AccountID, "")
Me!Combo124.DefaultValue = Nz(Me!LocationSuffixID, "")
Me!Combo80.DefaultValue = Nz(Me!AccountID, "")
Me!Amount.DefaultValue = 0
Else
End If
Set rst = Nothing
Set db = Nothing
End If
End Sub
I thought adding the latter field to the SQL would enable one to find the last record by ReceiptID and by receiptlocationID. Am I barking up the wrong tree or am I just barking? Any assistance would be greatfully received.
Ted.