Search Form (1 Viewer)

L0b0

Registered User.
Local time
Today, 04:34
Joined
Jan 25, 2019
Messages
22
I'm currently using this /forums/showthread.php?t=188663 to create a search form. This works great but I would also like to add some text boxes to display the memo fields that are associated with the record that I select from the list box. How do I get the record that I select in the list box to bring up and populate the other boxes so I can see the memo fields? Only trying to view them and set them up so that the searcher can view whats been entered for the searched record and not accidentally alter anything.

Thanks
 

L0b0

Registered User.
Local time
Today, 04:34
Joined
Jan 25, 2019
Messages
22
Thanks! This is actually really nice, its opening the form I want now but its not displaying the value? On the second form I set the record source to my same query and the fields unbound. One of the fields I am trying to get the info into on my second form is labeled Retailer but so is my query column.

On my list box I set up a double click event
Code:
Private Sub SearchResults_DblClick(Cancel As Integer)
DoCmd.OpenForm "FRM_SearchDetails", , , "Retailer = '" & Me.SearchResults & "'"
End Sub

What am I doing wrong? It is text btw.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:34
Joined
Aug 30, 2003
Messages
36,118
The form is opening but not with data? Does SearchResults contain the appropriate value? Could Retailer be a lookup field, and a number is expected? Can you attach the db here?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:34
Joined
Aug 30, 2003
Messages
36,118
Oh, and since it's a listbox you may need to refer to a column if retailer isn't the bound column.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:34
Joined
May 21, 2018
Messages
8,463
Code:
DoCmd.OpenForm "FRM_SearchDetails", , , "Retailer = '" & Me.SearchResults.Column(2) & "'"

See PBaldy's previous post mentioning this. Your retailer is in the third column. Or leave your code as is and change the bound column.
 

L0b0

Registered User.
Local time
Today, 04:34
Joined
Jan 25, 2019
Messages
22
Thats weird cause its not showing the .column(2) on my end. I changed it to .column(3) to fix it? But its not showing still?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:34
Joined
May 21, 2018
Messages
8,463
Columns are numbered 0 to N. This includes the hidden columns. Look at the actual row source.

Select field0, Field1, Field2 ....
 

L0b0

Registered User.
Local time
Today, 04:34
Joined
Jan 25, 2019
Messages
22
Code:
SELECT [QRY_SearchAll].[Ref Date], [QRY_SearchAll].[Representative], [QRY_SearchAll].[Retailer], [QRY_SearchAll].[City], [QRY_SearchAll].[State], [QRY_SearchAll].[Contact], [QRY_SearchAll].[Time In], [QRY_SearchAll].[Time Out] FROM QRY_SearchAll ORDER BY [Retailer], [Ref Date], [Representative], [City];

Is in my listboxs row source right now. changing it is breaking it for me? The plan is for it to populate all the fields in the details popup when it is double clicked. Do you have a example by chance?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:34
Joined
Aug 30, 2003
Messages
36,118
Column(2) would be correct. Make sure the column count property of the listbox is at least 3. It should be however many fields are returned by the SQL.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:34
Joined
Aug 30, 2003
Messages
36,118
Happy to help and welcome to the site by the way!
 

L0b0

Registered User.
Local time
Today, 04:34
Joined
Jan 25, 2019
Messages
22
Slight dig, but if I wanted to convert this now to a web form, is there any way of doing that? Could I pull off the same code with just a macro?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:34
Joined
Aug 30, 2003
Messages
36,118
I don't use macros, but the OpenForm action has the same wherecondition argument. If memory serves, the syntax is a little different.
 

L0b0

Registered User.
Local time
Today, 04:34
Joined
Jan 25, 2019
Messages
22
Yea I managed to get the macro for the open form. Just trying to get the syntax right for the search. Thanks
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:34
Joined
Aug 30, 2003
Messages
36,118
From help:

To open a form and restrict its records to those specified by the value of a control on another form, use the following expression:

[ fieldname ] = Forms![ formname ]![ controlname on other form ]

Replace fieldname with the name of a field in the underlying table or query of the form you want to open. Replace formname and controlname on other form with the name of the other form and the control on the other form that contains the value you want records in the first form to match.
 

Users who are viewing this thread

Top Bottom