TurboDieselOne
Registered User.
- Local time
- Today, 16:36
- Joined
- Jan 16, 2003
- Messages
- 39
I cannot get the Previous Button Working. the Next Button code worjks Find for now no error trapping yet and also the recordset is opened when a cmdbutton is clicke not when the form opens.
Option Compare Database
Option Explicit
Private Sub cmdClear_Click()
Dim db As Database
Dim rst As DAO.Recordset
Set rst = Nothing
Set db = Nothing
int1.Value = Null
txt2 = Null
txt3 = Null
txt4 = Null
txt5 = Null
txt6 = Null
cbo7 = Null
cbo8 = Null
txt9 = Null
dte10 = Null
dte11 = Null
End Sub
Private Sub cmdClients_Click()
Dim db As Database
Dim rst As DAO.Recordset
'open the recordset, but don't close it
Set db = CurrentDb
Set rst = db.OpenRecordset("qryClient")
'capture all records
Do While Not (rst.EOF)
rst.MoveNext
Loop
'move to the begining
rst.MoveFirst
'assign the first value
int1.Value = rst!ClientID
txt2 = rst!ClientName
txt3 = rst!Address1
txt4 = rst!VATNo
txt5 = rst!OurRef
txt6 = rst!ThereRef
cbo7 = rst!FeeEarner
cbo8 = rst!LegalExpenseInsurer
txt9 = rst!Notes
dte10 = rst!StartDate
dte11 = rst!EndDate
'disable the previous button
CmdPrevious.Enabled = False
Me.lbl1.Caption = "ClientID"
Me.lbl1.FontBold = True
End Sub
Private Sub cmdClose_Click()
Dim db As Database
Dim rst As DAO.Recordset
Set rst = Nothing
Set db = Nothing
DoCmd.Close
End Sub
Private Sub cmdNext_Click()
Dim db As Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("qryClient")
rst.MoveNext
int1.Value = rst!ClientID
txt2 = rst!ClientName
txt3 = rst!Address1
txt4 = rst!VATNo
txt5 = rst!OurRef
txt6 = rst!ThereRef
cbo7 = rst!FeeEarner
cbo8 = rst!LegalExpenseInsurer
txt9 = rst!Notes
dte10 = rst!StartDate
dte11 = rst!EndDate
CmdPrevious.Enabled = True
End Sub
Private Sub cmdPrevious_Click()
Dim db As Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("qryClient")
rst.MovePrevious
int1.SetFocus
int1.Value = rst!ClientID
txt2 = rst!ClientName
txt3 = rst!Address1
txt4 = rst!VATNo
txt5 = rst!OurRef
txt6 = rst!ThereRef
cbo7 = rst!FeeEarner
cbo8 = rst!LegalExpenseInsurer
txt9 = rst!Notes
dte10 = rst!StartDate
dte11 = rst!EndDate
End Sub
Private Sub Form_Load()
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
End Sub
Also the navigation buttons have to work on more than one recordset so if the cmdClient is pressed the qryClients is the recordset and if suppliers is clicked the navigation buttons have to work with supplier qry
Thanks in advance
Option Compare Database
Option Explicit
Private Sub cmdClear_Click()
Dim db As Database
Dim rst As DAO.Recordset
Set rst = Nothing
Set db = Nothing
int1.Value = Null
txt2 = Null
txt3 = Null
txt4 = Null
txt5 = Null
txt6 = Null
cbo7 = Null
cbo8 = Null
txt9 = Null
dte10 = Null
dte11 = Null
End Sub
Private Sub cmdClients_Click()
Dim db As Database
Dim rst As DAO.Recordset
'open the recordset, but don't close it
Set db = CurrentDb
Set rst = db.OpenRecordset("qryClient")
'capture all records
Do While Not (rst.EOF)
rst.MoveNext
Loop
'move to the begining
rst.MoveFirst
'assign the first value
int1.Value = rst!ClientID
txt2 = rst!ClientName
txt3 = rst!Address1
txt4 = rst!VATNo
txt5 = rst!OurRef
txt6 = rst!ThereRef
cbo7 = rst!FeeEarner
cbo8 = rst!LegalExpenseInsurer
txt9 = rst!Notes
dte10 = rst!StartDate
dte11 = rst!EndDate
'disable the previous button
CmdPrevious.Enabled = False
Me.lbl1.Caption = "ClientID"
Me.lbl1.FontBold = True
End Sub
Private Sub cmdClose_Click()
Dim db As Database
Dim rst As DAO.Recordset
Set rst = Nothing
Set db = Nothing
DoCmd.Close
End Sub
Private Sub cmdNext_Click()
Dim db As Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("qryClient")
rst.MoveNext
int1.Value = rst!ClientID
txt2 = rst!ClientName
txt3 = rst!Address1
txt4 = rst!VATNo
txt5 = rst!OurRef
txt6 = rst!ThereRef
cbo7 = rst!FeeEarner
cbo8 = rst!LegalExpenseInsurer
txt9 = rst!Notes
dte10 = rst!StartDate
dte11 = rst!EndDate
CmdPrevious.Enabled = True
End Sub
Private Sub cmdPrevious_Click()
Dim db As Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("qryClient")
rst.MovePrevious
int1.SetFocus
int1.Value = rst!ClientID
txt2 = rst!ClientName
txt3 = rst!Address1
txt4 = rst!VATNo
txt5 = rst!OurRef
txt6 = rst!ThereRef
cbo7 = rst!FeeEarner
cbo8 = rst!LegalExpenseInsurer
txt9 = rst!Notes
dte10 = rst!StartDate
dte11 = rst!EndDate
End Sub
Private Sub Form_Load()
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
End Sub
Also the navigation buttons have to work on more than one recordset so if the cmdClient is pressed the qryClients is the recordset and if suppliers is clicked the navigation buttons have to work with supplier qry
Thanks in advance