View Full Version : ListBoxes again


NigelShaw
03-05-2008, 01:34 PM
Hi,

i am looking for advice on listboxes. i have various books which all happily state everything exept how to use them!!

1st advice-

i need to know how to create an SQL statement on the listbox so it shows filtered dsata from a query. i am trying to filter by date so the list box could show multiple items carried out on the same date. is it:
SELECT Query.Field From Query Where Field

2nd advice-

a listbox shows data based on a query showing payments. i click on the payment in the listbox and a form opens with the specific data showing.
i have looked around but cannot find much on them.

help would be gratefully received as im currently stuck.


thanks,

NS

NigelShaw
03-05-2008, 01:42 PM
Ok,

i have partly figured one using the wizard only it works but just partly. i have set some code in the onclick of the listbox which should open the form relative to the filter:

Private Sub List36_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ExpandedPaymentsQry"
stLinkCriteria = "[PaymentNoID]=" & Me.PaymentNoID
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

regs,

NS

NigelShaw
03-05-2008, 02:58 PM
Hi,

can the listbox be visible if the data is null? when the data goes, so does the box!! i would like it to stay.

NS

WayneRyan
03-06-2008, 10:25 AM
NS,

I think that the lack of response might be due to a lack of something
tangible to work with.

Can you post a small sample?

Wayne

NigelShaw
03-07-2008, 03:54 AM
Hi Wayne,

i will create a sample of what i trying to achieve. i think i miht be there though. here is what i have done so far-
on the listbox RowSource SELECT [Query].[Field1],[Query].Field2] FROM [Query]
( Field2 is the unique id of the person i need relating to )

on the Query, set the criteria of the person i need to relating to a control on the form
( Criteria = Forms![Form]![Field] )

on the form, placed a non visible control with the unique ID.

so....
when the form is opened, the listbox queries the query, the query is filtered to the unique id, only info for the specifc record is shown.

currently, this works fine uless there is a better way.


in regard to the listbox being visible, when it hold data, i can see the list box as a white box with text. when there is no data to show, the list box is not visible. can the box be visible without data? the same with datasheet view. if there are no records, it shows 1 empty line. can it show a full set of empty lines like say Excel worksheet type?


thanks,


Nigel