473,426 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

Dynamicaly created where clause for OpenForm

Ok, I have read this group until I think my eyes are ready to bleed, so
I would be most appreciative of some help.

I have a form, on it are 3 combo boxes, and 3 text boxes
I have 1 table, with about 20 columns
Each of the 3 combo boxes is set to be a field list from the table
All 6 boxes are unbound
I have an Ok button, and a Cancel button

I have a second form with only a listbox that is bound to the table and
is set to display the columns I like the best.

What I am trying to do, is have the user pull down one or more combo
boxes to display which column they would like to search, put their
search criteria into the text box, and click Ok.

The table is Oper_Log
The search form is SearchForm
The results form is DisplayResults

The Objective is that the DisplayResults form would show in it's list
box the results of the persons search.

Down the road I want to be able to double click on a single record in
the list box and have it display a report I have that is a 1 page
report intended for single records. But I'm happy enuf if someone can
help with just this part!!!!! =)

The following code has gone through numerous morphications before
reaching this point, so has some inconsistencies. It should however at
least illustrate for the most part what I am trying to do.

Private Sub ButtonOk_Click()
On Error GoTo Err_ButtonOk_Click

Dim stSF1 As String
Dim stSC1 As String
Const cQ = """"

stSF1 = "Forms![SearchForm]![SearchField1]"
stSC1 = "Forms![SearchForm]![SearchCriteria1]"
If Not (IsNull(Forms![SearchForm]![SearchField3]) Or
Forms![SearchForm]![SearchField3] = " ") Then
GoTo ButtonOkThree
If Not (IsNull(Forms![SearchForm]![SearchField2]) Or
Forms![SearchForm]![SearchField2] = " ") Then
GoTo ButtonOkTwo
If Not (IsNull(Forms![SearchForm]![SearchField3])
Or Forms![SearchForm]![SearchField3] = " ") Then
GoTo ButtonOkOne
End If
End If
End If

ButtonOkOne:

DoCmd.OpenForm "DisplayResults", , , , "stSF1 = stSC1",
acFormReadOnly
ButtonOkTwo:

DoCmd.OpenForm "DisplayResults", , , " &
Forms![SearchForm]![SearchField1] & " = " &
Forms![SearchForm]![SearchCriteria1] & " And " &
Forms![SearchForm]![SearchField2] & " = " &
Forms![SearchForm]![SearchCriteria2] & ", acFormReadOnly

ButtonOkThree:

DoCmd.OpenForm "DisplayResults", , , " &
Forms![SearchForm]![SearchField1] & " = " &
Forms![SearchForm]![SearchCriteria1] & " And " &
Forms![SearchForm]![SearchField2] & " = " &
Forms![SearchForm]![SearchCriteria2] & " And " &
Forms![SearchForm]![SearchField3] & " = " &
Forms![SearchForm]![SearchCriteria3] & ", acFormReadOnly

Exit_ButtonOk_Click:
Exit Sub

Err_ButtonOk_Click:
MsgBox Err.Description
Resume Exit_ButtonOk_Click

End Sub
I Thank you VERY much for any assistance you can give!!!

Jason

Dec 19 '05 #1
3 1461
"griffiji" <gr******@aruplab.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Ok, I have read this group until I think my eyes are ready to bleed, so
I would be most appreciative of some help.

The question I have is, will "filter by form" not give you what you want for
free? I did once develop a bespoke search facility which I'm sure I could
dig up if you'd like me to send you a copy. It might not be exactly what
you want but it might point you in the right direction ...

Keith.
www.keithwilby.com
Dec 19 '05 #2
Ok, don't I feel like an idjit =)

So then, I filter by form, and then how do I pass the filtered
recordset to the second form?

And can I make filter by form a part of my code for the button that
launches the second form?

Dec 19 '05 #3
Bleh, that can't work, because the Fields of the form are unbound. I
was mistaken when I thought that filter by form had actually done
anything =)

Dec 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul | last post by:
I am trying to get a form to dynamicaly add hidden elements. Below is the function I've created, basicaly it loops thru an array and attempts to add those values to a newly created hidden input...
4
by: ZhangZQ | last post by:
Is it possible to dynamicaly to local and call a function in Win32 dll(not a ..net assembly dll) in C# at run time, for example, a C# program popup a dialogbox to let use input which Win32 dll to...
3
by: minigitoo | last post by:
Hi I try to get dynamicaly all requests made to DB2 I process like this: 1) I stop then start my instance of database in the db2 control center 2) I use : db2 update monitor switches using...
1
by: Roman Muntyanu | last post by:
Hi all, I created resource dll dynamicaly using this code AppDomain curDom = AppDomain.CurrentDomain; AssemblyName myAssemblyName = new AssemblyName(); imagesAssemblyName.Name = "Images";...
4
by: nicholas | last post by:
I tried to set the ID of a radiobuttonlist dynamicaly like this: <asp:RadioButtonList id="<%# DataBinder.Eval(Container.DataItem, "optionnameFR") %>" runat="server" ></asp:RadioButtonList> ...
8
by: Mike Charney | last post by:
I am trying to write an Open Form command in VBA with a where clause in it. I need to be able to do two different where clauses: 1) With a between in it: i.e. Between Date1 and Date2 or...
7
by: Mike Charney | last post by:
Can anyone tell me why the following statement doesnt work? DoCmd.OpenForm "frmSearchResults", , , "text24 Like *" & filter1 & "*" Field text24 is the field on teh results form that I am trying...
3
by: Mike Charney | last post by:
I am having trouble with the where clause in an openreport statement in an Access Data Project. I am using MS-Access 2003 with SQL Svr 2000. The line I am using is: DoCmd.OpenReport...
14
by: keri | last post by:
Hi, Simple version of the question..... How do I use the where clause of the open form command to show an account with a matching ID to be displayed when the form is opened? Eg. I select a...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.