Cant Get Previous Working (1 Viewer)

TurboDieselOne

Registered User.
Local time
Today, 01:20
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
 

TurboDieselOne

Registered User.
Local time
Today, 01:20
Joined
Jan 16, 2003
Messages
39
Well what I want is one form with menu buttons down the left but no fields when the form loads. Press the button "Clients" and the code runs on the cmdClients_Click() that draws the unbound fields creates the rowsources for any combos and then loads the recordset intialises the navigation and undo and save buttons along the bottom of the form to work with the record set. Then when you have finished you clear the form after unloading the recordset of course and select another like Suppliers. then we go through the whole thing again but with recordset belonging to table or qry suppliers.

I suppose in a way I am using it as a complete VB project rather than A VBA or access thing. This is because I have VBSTUDIo 6.0 but I don't want to install it on my home machine and I am not experienced enough to write and compile a complete application but I will convert the database at sometime

Complicated?
 

Oldsoftboss

AWF VIP
Local time
Today, 10:20
Joined
Oct 28, 2001
Messages
2,499
You are far better to make a form with all the field and buttons etc and then use your menu buttons to make the fields etc visible. Creating controls on the fly requires the form to be in design mode and you must keep in mind that an access form can only have a limited no of controls (about 700 I think), so if you create 20 controls each time and do this 35 - 40 times then the form will throw up errors.

By making the field visible the only thing that you may have to do set the record source for the form.

Dave
 

Oldsoftboss

AWF VIP
Local time
Today, 10:20
Joined
Oct 28, 2001
Messages
2,499
You could try something like this....
 

Attachments

  • oneway.zip
    46 KB · Views: 116

Users who are viewing this thread

Top Bottom