G
Guest
I am not binding my table to the form. Prefer the learning experience of
coding everything myself. When I initially populate the text boxes on the
form with data from the first record, I get data from the next record ( or
the last record as there are only two records in the table for now). I then
rewrite to MoveLast ( the opposite of above) and it returns the first record!
The Index of the table is the auto number field SessionID which the first
record is 1 and the next record is a greater number. In fact all the indexes
should return the first record.
Public Function PopulateForm(frm As Form) As Boolean
Dim db As Database
Dim rec As Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblSessions")
If rec.RecordCount = 0 Then
PopulateForm = False
Exit Function
End If
rec.MoveFirst
frm!txtSessionDate.Value = rec("SessionDate")
frm!txtGame.Value = rec("Game")
frm!txtHours.Value = rec("Hours")
frm!txtWinLoss.Value = rec("WinLoss")
frm!txtCasino.Value = rec("Casino")
frm!txtBankroll.Value = rec("Bankroll")
curLastBank = rec("Bankroll")
If Not rec("BankUpdate") Then
rec("BankUpdate") = True
End If
frm!txtSessionID.Value = rec("SessionID")
Debug.Print rec("sessionID")
PopulateForm = True
End Function
Here's the data from the table:
SessionID SessionDate Game Hours WinLoss Casino Bankroll BankUpdate
1 Monday, July 25, 2005 Limit Holdem: Limit 8/16 1.5 $167.00 Bicycle
Casino $10,167.00 Yes
11 Tuesday, July 26, 2005 Limit Holdem: Limit 6/12 1.25 $154.00 Hawaiian
Gardens Casino $10,321.00 Yes
Anyone have any ideas? As it is, I am unable to write the record navigation
code to attach to the form buttons. First Previous Next Last New that
disables and enables the buttons based on where the record pointer is at.
coding everything myself. When I initially populate the text boxes on the
form with data from the first record, I get data from the next record ( or
the last record as there are only two records in the table for now). I then
rewrite to MoveLast ( the opposite of above) and it returns the first record!
The Index of the table is the auto number field SessionID which the first
record is 1 and the next record is a greater number. In fact all the indexes
should return the first record.
Public Function PopulateForm(frm As Form) As Boolean
Dim db As Database
Dim rec As Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblSessions")
If rec.RecordCount = 0 Then
PopulateForm = False
Exit Function
End If
rec.MoveFirst
frm!txtSessionDate.Value = rec("SessionDate")
frm!txtGame.Value = rec("Game")
frm!txtHours.Value = rec("Hours")
frm!txtWinLoss.Value = rec("WinLoss")
frm!txtCasino.Value = rec("Casino")
frm!txtBankroll.Value = rec("Bankroll")
curLastBank = rec("Bankroll")
If Not rec("BankUpdate") Then
rec("BankUpdate") = True
End If
frm!txtSessionID.Value = rec("SessionID")
Debug.Print rec("sessionID")
PopulateForm = True
End Function
Here's the data from the table:
SessionID SessionDate Game Hours WinLoss Casino Bankroll BankUpdate
1 Monday, July 25, 2005 Limit Holdem: Limit 8/16 1.5 $167.00 Bicycle
Casino $10,167.00 Yes
11 Tuesday, July 26, 2005 Limit Holdem: Limit 6/12 1.25 $154.00 Hawaiian
Gardens Casino $10,321.00 Yes
Anyone have any ideas? As it is, I am unable to write the record navigation
code to attach to the form buttons. First Previous Next Last New that
disables and enables the buttons based on where the record pointer is at.