Re: Open a Form defined by combo
- From: Marshall Barton <marshbarton@xxxxxxxxxx>
- Date: Thu, 13 Oct 2005 09:16:40 -0500
Lana wrote:
>I was thinking about using the same form for displaying the results, but my
>task is a bit complicated and i am not sure if it is possible to do so.
>
>Let me explain the situation - may be you can give me some advise:
>
>I have a table with fields "A", "B", "C", etc. (12 fields).
>My [Main] form is for search. It has a combo with a rowsource from other
>small table with only 12 records which contain the names of the 12 fields of
>the other table ("A", "B", "C", etc.)
>Depending on what was value chosen in this combo-box, I want to perform
>search in one of the 12 fields of the big table and return results in another
>form.
>
>The reason why I was using 12 forms instead of 1 is that I dont know how to
>alter the control source of the text-box so that it would display the records
>of different fields depending on the value chosen from combobox. (And it must
>change the formatting of the text-box as well - like using different Fonts
>for some of the 12 fields)
>
>Each of my 12 forms are based on 12 queries (so the query would run on
>opening the form).
>
>They are actually selection queries very similar to each other. I would love
>to use one query instead of 12, but dont know how. :(
>They have a condition like:
>Querry A:
>WHERE ((([BigTable]![A]) Like ("*"+[Find]+"*")));
>Querry B:
>WHERE ((([BigTable]![B]) Like ("*"+[Find]+"*")));
>
>I guess you could use one query for all of them, but I dont know how to
>introduce the dependance to the combobox value in here neither.
>
>All this code writing thing seems so complicated to me. I feel that there
>should be a good solution for all that, but dont have a slightest idea how to
>do that.
>
>
>> Lana wrote:
>> >I got a [Combo709] on my [Main] form with some values ("A", "B", "C", etc.)
>> >which i want to use to open different forms. The forms names are: "F_A",
>> >"F_B", "F_C", etc.
>> >
>> >I was trying to make a button for this, but when I click it, I get a message
>> >"The action or method requires a Form Name argument".
>> >
>> >I am not really good at writing codes - can somebody show me what is wrong
>> >here?
>> >
>> >Here is the code for my button:
>> >
>> >Private Sub Command707_Click()
>> >On Error GoTo Err_Command707_Click
>> >
>> > Dim stDocName As String
>> > Dim stLinkCriteria As String
>> >
>> >If Me.Combo709 = "A" Then
>> > stDocName = "F_A"
>> >ElseIf Me.Combo709 = "B" Then
>> > stDocName = "F_B"
>> >
>> > End If
>> > DoCmd.OpenForm stDocName, , , stLinkCriteria
>> [snip]
>>
>>
>"Marshall Barton" wrote:
>> From your description, I would expect that to work if the
>> combo box's value is either an "A" or a "B". Are you sure
>> that the combo box's Value is what you think it is? What is
>> the combo box's Bound column and what setting so you have
>> for the ColumnWidths property.
>>
>> You can probably shorten this dramatically by using this
>> code instead:
>>
>> Private Sub Command707_Click()
>> On Error GoTo Err_Command707_Click
>>
>> Dim stDocName As String
>>
>> stDocName = "F_" & Me.Combo709
>> DoCmd.OpenForm stDocName
>> . . .
>>
>> However, I have a serious suspicion that this entire
>> scenario has gone astray somewhere earlier. It just doesn't
>> seem right to need different forms for whatever reason it is
>> you are making the combo box selection.
--
Marsh
MVP [MS Access]
.
- References:
- Open a Form defined by combo
- From: Lana
- Re: Open a Form defined by combo
- From: Marshall Barton
- Open a Form defined by combo
- Prev by Date: Re: RunSQL - I've searched!!
- Next by Date: Re: Late Binding -- Member Not Found
- Previous by thread: Re: Open a Form defined by combo
- Next by thread: String with "'" in Customer name
- Index(es):