Below is my code to give me a PAGING type form...I currently have a form with text and combo boxes that pass parameters to a query and it works fine...the problem is the output only returns one item per page....I solved this by using my paging code for this form...but I want to set it up so a user can go to the combo/list boxes and it will limit the results accordingly....please help!!!
Option Compare Database
Option Explicit
Dim cn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim CurrentPage
Private Sub Form_Load()
CurrentPage = 1
Set cn = CurrentProject.Connection
Set rst = New ADODB.Recordset
With rst
.PageSize = 8
.ActiveConnection = cn
.Source = "select Development.[KinderNumber],Development.[family],Development.[Intro_Date],Development.[Client],Development.[MFG],Development.[Fixture],Development.[Dimensions (HxWxD)],Development.[MFG Price],Development.[Item Number], dp.[Image], dp.[Revision_ Letter] FROM developmentpictures dp RIGHT JOIN Development ON dp.[kindernum] = development.[kindernumber] WHERE dp.[Revision_ Letter] IN(select max([Revision_ Letter]) from developmentpictures where kindernum = dp.kindernum)ORDER BY Development.[Client], Development.[MFG],development.[intro_date],development.[Family]"
.LockType = adLockOptimistic
.CursorType = adOpenStatic
.Open
End With
'Set Me.Recordset = rst
UpdateControls
End Sub
Private Sub NextBtn_Click()
CurrentPage = CurrentPage + 1
UpdateControls
End Sub
Private Sub PrevBtn_Click()
CurrentPage = CurrentPage - 1
UpdateControls
End Sub
Private Sub UpdateControls()
Dim NumPages
Dim NumRecs
' Get the number of pages and records
NumPages = rst.PageCount
NumRecs = rst.RecordCount
PageLabel.Value = "Page " & CurrentPage & " of " & NumPages
If CurrentPage > NumPages Then CurrentPage = NumPages
If CurrentPage < 1 Then CurrentPage = 1
' Set the page we want to display
rst.AbsolutePage = CurrentPage
If CurrentPage = NumPages Then
DoCmd.GoToControl "dbpixctl1"
NextBtn.Enabled = False
Else
NextBtn.Enabled = True
End If
If (Not rst.EOF) Then
dbpixctl1.IMAGE = rst("Image"
Txtkn1.Value = rst("KinderNumber"
TxtDate1.Value = rst("Intro_Date"
Txtclient1.Value = rst("Client"
Txtmfg1.Value = rst("MFG"
Txtfix1.Value = rst("Fixture"
Txtdim1.Value = rst("Dimensions (HxWxD)"
Txtin1.Value = rst("Item Number"
txtmp1.Value = rst("MFG price"
Txtrev1.Value = rst("Revision_ Letter"
txtfam1.Value = rst("Family"
rst.MoveNext
Else
dbpixctl1.IMAGE = ""
Txtkn1.Value = ""
TxtDate1.Value = ""
Txtclient1.Value = ""
Txtmfg1.Value = ""
Txtfix1.Value = ""
Txtdim1.Value = ""
Txtin1.Value = ""
txtmp1.Value = ""
Txtrev1.Value = ""
txtfam1.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl2.IMAGE = rst("Image"
Txtkn2.Value = rst("KinderNumber"
txtDate2.Value = rst("Intro_Date"
Txtclient2.Value = rst("Client"
Txtmfg2.Value = rst("MFG"
Txtfix2.Value = rst("Fixture"
Txtdim2.Value = rst("Dimensions (HxWxD)"
Txtin2.Value = rst("Item Number"
Txtmp2.Value = rst("MFG price"
Txtrev2.Value = rst("Revision_ Letter"
txtfam2.Value = rst("Family"
rst.MoveNext
Else
dbpixctl2.IMAGE = ""
Txtkn2.Value = ""
txtDate2.Value = ""
Txtclient2.Value = ""
Txtmfg2.Value = ""
Txtfix2.Value = ""
Txtdim2.Value = ""
Txtin2.Value = ""
Txtmp2.Value = ""
Txtrev2.Value = ""
txtfam2.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl3.IMAGE = rst("Image"
Txtkn3.Value = rst("KinderNumber"
txtdate3.Value = rst("Intro_Date"
Txtclient3.Value = rst("Client"
Txtmfg3.Value = rst("MFG"
txtfix3.Value = rst("Fixture"
Txtdim3.Value = rst("Dimensions (HxWxD)"
Txtin3.Value = rst("Item Number"
Txtmp3.Value = rst("MFG price"
Txtrev3.Value = rst("Revision_ Letter"
txtfam3.Value = rst("Family"
rst.MoveNext
Else
dbpixctl3.IMAGE = ""
Txtkn3.Value = ""
txtdate3.Value = ""
Txtclient3.Value = ""
Txtmfg3.Value = ""
txtfix3.Value = ""
Txtdim3.Value = ""
Txtin3.Value = ""
Txtmp3.Value = ""
Txtrev3.Value = ""
txtfam3.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl4.IMAGE = rst("Image"
Txtkn4.Value = rst("KinderNumber"
txtdate4.Value = rst("Intro_Date"
Txtclient4.Value = rst("Client"
Txtmfg4.Value = rst("MFG"
Txtfix4.Value = rst("Fixture"
Txtdim4.Value = rst("Dimensions (HxWxD)"
Txtin4.Value = rst("Item Number"
Txtmp4.Value = rst("MFG price"
Txtrev4.Value = rst("Revision_ Letter"
txtfam4.Value = rst("Family"
rst.MoveNext
Else
dbpixctl4.IMAGE = ""
Txtkn4.Value = ""
txtdate4.Value = ""
Txtclient4.Value = ""
Txtmfg4.Value = ""
Txtfix4.Value = ""
Txtdim4.Value = ""
Txtin4.Value = ""
Txtmp4.Value = ""
Txtrev4.Value = ""
txtfam4.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl5.IMAGE = rst("Image"
Txtkn5.Value = rst("KinderNumber"
txtdate5.Value = rst("Intro_Date"
Txtclient5.Value = rst("Client"
Txtmfg5.Value = rst("MFG"
Txtfix5.Value = rst("Fixture"
Txtdim5.Value = rst("Dimensions (HxWxD)"
Txtin5.Value = rst("Item Number"
Txtmp5.Value = rst("MFG price"
Txtrev5.Value = rst("Revision_ Letter"
txtfam5.Value = rst("Family"
rst.MoveNext
Else
dbpixctl5.IMAGE = ""
Txtkn5.Value = ""
txtdate5.Value = ""
Txtclient5.Value = ""
Txtmfg5.Value = ""
Txtfix5.Value = ""
Txtdim5.Value = ""
Txtin5.Value = ""
Txtmp5.Value = ""
Txtrev5.Value = ""
txtfam5.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl6.IMAGE = rst("Image"
Txtkn6.Value = rst("KinderNumber"
txtdate6.Value = rst("Intro_Date"
Txtclient6.Value = rst("Client"
Txtmfg6.Value = rst("MFG"
Txtfix6.Value = rst("Fixture"
Txtdim6.Value = rst("Dimensions (HxWxD)"
Txtin6.Value = rst("Item Number"
Txtmp6.Value = rst("MFG price"
Txtrev6.Value = rst("Revision_ Letter"
Txtfam6.Value = rst("Family"
rst.MoveNext
Else
dbpixctl6.IMAGE = ""
Txtkn6.Value = ""
txtdate6.Value = ""
Txtclient6.Value = ""
Txtmfg6.Value = ""
Txtfix6.Value = ""
Txtdim6.Value = ""
Txtin6.Value = ""
Txtmp6.Value = ""
Txtrev6.Value = ""
Txtfam6.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl7.IMAGE = rst("Image"
Txtkn7.Value = rst("KinderNumber"
txtdate7.Value = rst("Intro_Date"
Txtclient7.Value = rst("Client"
Txtmfg7.Value = rst("MFG"
Txtfix7.Value = rst("Fixture"
Txtdim7.Value = rst("Dimensions (HxWxD)"
Txtin7.Value = rst("Item Number"
Txtmp7.Value = rst("MFG price"
Txtrev7.Value = rst("Revision_ Letter"
txtfam7.Value = rst("Family"
rst.MoveNext
Else
dbpixctl7.IMAGE = ""
Txtkn7.Value = ""
txtdate7.Value = ""
Txtclient7.Value = ""
Txtmfg7.Value = ""
Txtfix7.Value = ""
Txtdim7.Value = ""
Txtin7.Value = ""
Txtmp7.Value = ""
Txtrev7.Value = ""
txtfam7.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl8.IMAGE = rst("Image"
Txtkn8.Value = rst("KinderNumber"
txtdate8.Value = rst("Intro_Date"
Txtclient8.Value = rst("Client"
Txtmfg8.Value = rst("MFG"
Txtfix8.Value = rst("Fixture"
Txtdim8.Value = rst("Dimensions (HxWxD)"
Txtin8.Value = rst("Item Number"
Txtmp8.Value = rst("MFG price"
Txtrev8.Value = rst("Revision_ Letter"
Txtfam8.Value = rst("Family"
rst.MoveNext
Else
dbpixctl8.IMAGE = ""
Txtkn8.Value = ""
txtdate8.Value = ""
Txtclient8.Value = ""
Txtmfg8.Value = ""
Txtfix8.Value = ""
Txtdim8.Value = ""
Txtin8.Value = ""
Txtmp8.Value = ""
Txtrev8.Value = ""
Txtfam8.Value = ""
End If
End Sub
Option Compare Database
Option Explicit
Dim cn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim CurrentPage
Private Sub Form_Load()
CurrentPage = 1
Set cn = CurrentProject.Connection
Set rst = New ADODB.Recordset
With rst
.PageSize = 8
.ActiveConnection = cn
.Source = "select Development.[KinderNumber],Development.[family],Development.[Intro_Date],Development.[Client],Development.[MFG],Development.[Fixture],Development.[Dimensions (HxWxD)],Development.[MFG Price],Development.[Item Number], dp.[Image], dp.[Revision_ Letter] FROM developmentpictures dp RIGHT JOIN Development ON dp.[kindernum] = development.[kindernumber] WHERE dp.[Revision_ Letter] IN(select max([Revision_ Letter]) from developmentpictures where kindernum = dp.kindernum)ORDER BY Development.[Client], Development.[MFG],development.[intro_date],development.[Family]"
.LockType = adLockOptimistic
.CursorType = adOpenStatic
.Open
End With
'Set Me.Recordset = rst
UpdateControls
End Sub
Private Sub NextBtn_Click()
CurrentPage = CurrentPage + 1
UpdateControls
End Sub
Private Sub PrevBtn_Click()
CurrentPage = CurrentPage - 1
UpdateControls
End Sub
Private Sub UpdateControls()
Dim NumPages
Dim NumRecs
' Get the number of pages and records
NumPages = rst.PageCount
NumRecs = rst.RecordCount
PageLabel.Value = "Page " & CurrentPage & " of " & NumPages
If CurrentPage > NumPages Then CurrentPage = NumPages
If CurrentPage < 1 Then CurrentPage = 1
' Set the page we want to display
rst.AbsolutePage = CurrentPage
If CurrentPage = NumPages Then
DoCmd.GoToControl "dbpixctl1"
NextBtn.Enabled = False
Else
NextBtn.Enabled = True
End If
If (Not rst.EOF) Then
dbpixctl1.IMAGE = rst("Image"
Txtkn1.Value = rst("KinderNumber"
TxtDate1.Value = rst("Intro_Date"
Txtclient1.Value = rst("Client"
Txtmfg1.Value = rst("MFG"
Txtfix1.Value = rst("Fixture"
Txtdim1.Value = rst("Dimensions (HxWxD)"
Txtin1.Value = rst("Item Number"
txtmp1.Value = rst("MFG price"
Txtrev1.Value = rst("Revision_ Letter"
txtfam1.Value = rst("Family"
rst.MoveNext
Else
dbpixctl1.IMAGE = ""
Txtkn1.Value = ""
TxtDate1.Value = ""
Txtclient1.Value = ""
Txtmfg1.Value = ""
Txtfix1.Value = ""
Txtdim1.Value = ""
Txtin1.Value = ""
txtmp1.Value = ""
Txtrev1.Value = ""
txtfam1.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl2.IMAGE = rst("Image"
Txtkn2.Value = rst("KinderNumber"
txtDate2.Value = rst("Intro_Date"
Txtclient2.Value = rst("Client"
Txtmfg2.Value = rst("MFG"
Txtfix2.Value = rst("Fixture"
Txtdim2.Value = rst("Dimensions (HxWxD)"
Txtin2.Value = rst("Item Number"
Txtmp2.Value = rst("MFG price"
Txtrev2.Value = rst("Revision_ Letter"
txtfam2.Value = rst("Family"
rst.MoveNext
Else
dbpixctl2.IMAGE = ""
Txtkn2.Value = ""
txtDate2.Value = ""
Txtclient2.Value = ""
Txtmfg2.Value = ""
Txtfix2.Value = ""
Txtdim2.Value = ""
Txtin2.Value = ""
Txtmp2.Value = ""
Txtrev2.Value = ""
txtfam2.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl3.IMAGE = rst("Image"
Txtkn3.Value = rst("KinderNumber"
txtdate3.Value = rst("Intro_Date"
Txtclient3.Value = rst("Client"
Txtmfg3.Value = rst("MFG"
txtfix3.Value = rst("Fixture"
Txtdim3.Value = rst("Dimensions (HxWxD)"
Txtin3.Value = rst("Item Number"
Txtmp3.Value = rst("MFG price"
Txtrev3.Value = rst("Revision_ Letter"
txtfam3.Value = rst("Family"
rst.MoveNext
Else
dbpixctl3.IMAGE = ""
Txtkn3.Value = ""
txtdate3.Value = ""
Txtclient3.Value = ""
Txtmfg3.Value = ""
txtfix3.Value = ""
Txtdim3.Value = ""
Txtin3.Value = ""
Txtmp3.Value = ""
Txtrev3.Value = ""
txtfam3.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl4.IMAGE = rst("Image"
Txtkn4.Value = rst("KinderNumber"
txtdate4.Value = rst("Intro_Date"
Txtclient4.Value = rst("Client"
Txtmfg4.Value = rst("MFG"
Txtfix4.Value = rst("Fixture"
Txtdim4.Value = rst("Dimensions (HxWxD)"
Txtin4.Value = rst("Item Number"
Txtmp4.Value = rst("MFG price"
Txtrev4.Value = rst("Revision_ Letter"
txtfam4.Value = rst("Family"
rst.MoveNext
Else
dbpixctl4.IMAGE = ""
Txtkn4.Value = ""
txtdate4.Value = ""
Txtclient4.Value = ""
Txtmfg4.Value = ""
Txtfix4.Value = ""
Txtdim4.Value = ""
Txtin4.Value = ""
Txtmp4.Value = ""
Txtrev4.Value = ""
txtfam4.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl5.IMAGE = rst("Image"
Txtkn5.Value = rst("KinderNumber"
txtdate5.Value = rst("Intro_Date"
Txtclient5.Value = rst("Client"
Txtmfg5.Value = rst("MFG"
Txtfix5.Value = rst("Fixture"
Txtdim5.Value = rst("Dimensions (HxWxD)"
Txtin5.Value = rst("Item Number"
Txtmp5.Value = rst("MFG price"
Txtrev5.Value = rst("Revision_ Letter"
txtfam5.Value = rst("Family"
rst.MoveNext
Else
dbpixctl5.IMAGE = ""
Txtkn5.Value = ""
txtdate5.Value = ""
Txtclient5.Value = ""
Txtmfg5.Value = ""
Txtfix5.Value = ""
Txtdim5.Value = ""
Txtin5.Value = ""
Txtmp5.Value = ""
Txtrev5.Value = ""
txtfam5.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl6.IMAGE = rst("Image"
Txtkn6.Value = rst("KinderNumber"
txtdate6.Value = rst("Intro_Date"
Txtclient6.Value = rst("Client"
Txtmfg6.Value = rst("MFG"
Txtfix6.Value = rst("Fixture"
Txtdim6.Value = rst("Dimensions (HxWxD)"
Txtin6.Value = rst("Item Number"
Txtmp6.Value = rst("MFG price"
Txtrev6.Value = rst("Revision_ Letter"
Txtfam6.Value = rst("Family"
rst.MoveNext
Else
dbpixctl6.IMAGE = ""
Txtkn6.Value = ""
txtdate6.Value = ""
Txtclient6.Value = ""
Txtmfg6.Value = ""
Txtfix6.Value = ""
Txtdim6.Value = ""
Txtin6.Value = ""
Txtmp6.Value = ""
Txtrev6.Value = ""
Txtfam6.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl7.IMAGE = rst("Image"
Txtkn7.Value = rst("KinderNumber"
txtdate7.Value = rst("Intro_Date"
Txtclient7.Value = rst("Client"
Txtmfg7.Value = rst("MFG"
Txtfix7.Value = rst("Fixture"
Txtdim7.Value = rst("Dimensions (HxWxD)"
Txtin7.Value = rst("Item Number"
Txtmp7.Value = rst("MFG price"
Txtrev7.Value = rst("Revision_ Letter"
txtfam7.Value = rst("Family"
rst.MoveNext
Else
dbpixctl7.IMAGE = ""
Txtkn7.Value = ""
txtdate7.Value = ""
Txtclient7.Value = ""
Txtmfg7.Value = ""
Txtfix7.Value = ""
Txtdim7.Value = ""
Txtin7.Value = ""
Txtmp7.Value = ""
Txtrev7.Value = ""
txtfam7.Value = ""
End If
If (Not rst.EOF) Then
dbpixctl8.IMAGE = rst("Image"
Txtkn8.Value = rst("KinderNumber"
txtdate8.Value = rst("Intro_Date"
Txtclient8.Value = rst("Client"
Txtmfg8.Value = rst("MFG"
Txtfix8.Value = rst("Fixture"
Txtdim8.Value = rst("Dimensions (HxWxD)"
Txtin8.Value = rst("Item Number"
Txtmp8.Value = rst("MFG price"
Txtrev8.Value = rst("Revision_ Letter"
Txtfam8.Value = rst("Family"
rst.MoveNext
Else
dbpixctl8.IMAGE = ""
Txtkn8.Value = ""
txtdate8.Value = ""
Txtclient8.Value = ""
Txtmfg8.Value = ""
Txtfix8.Value = ""
Txtdim8.Value = ""
Txtin8.Value = ""
Txtmp8.Value = ""
Txtrev8.Value = ""
Txtfam8.Value = ""
End If
End Sub