Re: applying logic in form controls
- From: "Rob Oldfield" <blah@xxxxxxxx>
- Date: Fri, 28 Oct 2005 17:26:39 +0100
Hmm. Can you not see it in reply to your other reply?
"Pitu" <Pitu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CF2F5940-DBB6-4745-B8BD-6A263947600D@xxxxxxxxxxxxxxxx
> Hi Rob,
>
> I am still waiting for your reply. Let me know if you need more
information
> to answer. Please read the previous post for the details that you asked.
>
> "Pitu" wrote:
>
> > It says SELECT TriggerSourcetbl.id, TriggerSourcetbl.Triggersource FROM
> > TriggerSourcetbl; in rowsource on data tab and 0";1" on colum widths of
> > format tab.
> >
> >
> >
> > "Rob Oldfield" wrote:
> >
> > > ....and I'll explain in more detail what the problem is when I get
that back.
> > >
> > >
> > > "Pitu" <Pitu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > news:B1BF94CA-14D3-40DB-9881-2528598EADCB@xxxxxxxxxxxxxxxx
> > > > I am a learner so I have never used teh debugger but I followed the
steps
> > > > that you told. When i press F8 after select case statement it goes
to the
> > > > case "Other". after pressing F8 it goes to Case "NCR" and after
pressing
> > > F8
> > > > it goes to Case Else and then after pressing F8 it goes to Me.Text.
at
> > > every
> > > > point if i point cursor on select case statement it shows
> > > Me.TriggerSource =
> > > > 0. I don't understant what this means.
> > > >
> > > >
> > > >
> > > >
> > > > "Rob Oldfield" wrote:
> > > >
> > > > > Does triggersource display a value when the form loads? If not
then the
> > > > > case else statement will always kick in.
> > > > >
> > > > > The best way to test it is this:
> > > > >
> > > > > Go to the code window and right click the select case line.
Choose
> > > Toggle,
> > > > > Breakpoint. That line will be highlighted.
> > > > > Now close the code window and switch to form view. It should run
> > > through
> > > > > the code and stop when it reaches the breakpoint you just set.
> > > > > Hit F8. It will move to the next line to process.
> > > > > Hit F8 again... etc, etc.
> > > > >
> > > > > What happens?
> > > > >
> > > > >
> > > > > "Pitu" <Pitu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > > news:72EEB5F0-F9BE-4ADC-878F-C9CC4754474A@xxxxxxxxxxxxxxxx
> > > > > > Hi Rob,
> > > > > >
> > > > > > I tried doing what you mentioned but then the textbox is always
> > > showing
> > > > > the
> > > > > > value hi by default on form load. and also does not change when
the
> > > try to
> > > > > > select different values in the combobox. So looks like the code
is
> > > > > directly
> > > > > > going to the case else statement. Can you suggest anything for
this.
> > > > > >
> > > > > > "Rob Oldfield" wrote:
> > > > > >
> > > > > > > The actual error is because you're using the Text property,
which is
> > > > > only
> > > > > > > available when the control has the focus. (You can use it to
get at
> > > the
> > > > > > > current contents of a textbox while you're typing in it.)
> > > > > > >
> > > > > > > You're also missing an end if after the line Me.Text15 =
> > > "ncrjudgement"
> > > > > > >
> > > > > > > So it would need to be...
> > > > > > >
> > > > > > > Private Sub TriggerSource_AfterUpdate()
> > > > > > > Select Case Me.TriggerSource
> > > > > > > Case "Other"
> > > > > > > If Me.TriggerType = "Judgement" Then
> > > > > > > Me.Text15 = "otherjudgement"
> > > > > > > End If
> > > > > > > Case "NCR"
> > > > > > > If Me.TriggerType = "Judgement" Then
> > > > > > > Me.Text15 = "ncrjudgement"
> > > > > > > End If
> > > > > > > Case Else
> > > > > > > Me.Text15 = "hi"
> > > > > > > End Select
> > > > > > > End Sub
> > > > > > >
> > > > > > > Note that if triggersource is 'Other' and triggertype is
anything
> > > other
> > > > > than
> > > > > > > 'Judgement' then you're not going to be doing anything and
you'll
> > > just
> > > > > end
> > > > > > > up with whatever was in Text15 before.
> > > > > > >
> > > > > > > Last thing: you need to put this into one sub rather than
repeating
> > > > > three
> > > > > > > times. Somewhere in the form's code window (outside any of
your
> > > other
> > > > > > > routines) just add...
> > > > > > >
> > > > > > > private sub SetText15()
> > > > > > > Select Case Me.TriggerSource
> > > > > > > (and the rest of the corrected code)
> > > > > > > end sub
> > > > > > >
> > > > > > > then each of the after update events and the current event
would
> > > look
> > > > > > > like...
> > > > > > >
> > > > > > > Private Sub TriggerSource_AfterUpdate()
> > > > > > > SetText15
> > > > > > > End Sub
> > > > > > >
> > > > > > > If you have the code repeated three times then it becomes
cumbersome
> > > to
> > > > > > > remember to update all three when you make a change to the
logic.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > "Pitu" <Pitu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > > > > > news:39BD9F42-D86F-4C30-9C68-B9137BA3C21B@xxxxxxxxxxxxxxxx
> > > > > > > > this is just the test code. I have two combobox named
> > > TriggerSource
> > > > > and
> > > > > > > > TriggerType and name of the textbox is Text15. Triggersource
has
> > > list
> > > > > of
> > > > > > > > values- Other and NCR. whereas triggertype has value of
Judgement.
> > > > > Here is
> > > > > > > > the code that I wrote in triggersource_afterupdate event and
also
> > > > > > > > triggertype_afterupdate event as well as form_current event
which
> > > > > gives me
> > > > > > > an
> > > > > > > > error that you cannot reference property or method of a
control
> > > > > without
> > > > > > > > setting focus.
> > > > > > > >
> > > > > > > > Private Sub TriggerSource_AfterUpdate()
> > > > > > > > Select Case Me.TriggerSource.Text
> > > > > > > > Case "Other"
> > > > > > > > If Me.TriggerType.Text = "Judgement" Then
> > > > > > > > Me.Text15 = "otherjudgement"
> > > > > > > > End If
> > > > > > > > Case "NCR"
> > > > > > > > If Me.TriggerType.Text = "Judgement" Then
> > > > > > > > Me.Text15 = "ncrjudgement"
> > > > > > > >
> > > > > > > > Case Else
> > > > > > > > Me.Text15 = "hi"
> > > > > > > > End Select
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > Don't know what to do now
> > > > > > > >
> > > > > > > > "Pitu" wrote:
> > > > > > > >
> > > > > > > > > Thanks Rob,
> > > > > > > > >
> > > > > > > > > I got the idea so let me work on it and will ask if it
does not
> > > > > work.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > "Rob Oldfield" wrote:
> > > > > > > > >
> > > > > > > > > > Oops. Hit 'send' before I'd finished. That code would
go
> > > into a
> > > > > sub,
> > > > > > > which
> > > > > > > > > > would be called in the after update event of each of the
> > > combos
> > > > > (so
> > > > > > > that the
> > > > > > > > > > text box is immediately updated), and also in the
current
> > > event of
> > > > > the
> > > > > > > form
> > > > > > > > > > (so that it's updated when you move from record to
record).
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > "Rob Oldfield" <blah@xxxxxxxx> wrote in message
> > > > > > > > > > news:eK2%23Yky2FHA.3420@xxxxxxxxxxxxxxxxxxxxxxx
> > > > > > > > > > > The best syntax would depend on exactly what
conditions you
> > > want
> > > > > to
> > > > > > > use,
> > > > > > > > > > but
> > > > > > > > > > > it would probably be a combination of selects and ifs.
> > > > > Something
> > > > > > > like...
> > > > > > > > > > >
> > > > > > > > > > > select case me.cbo1
> > > > > > > > > > > case "a","b","c"
> > > > > > > > > > > if me.cbo2="x" then
> > > > > > > > > > > me.txt1="Yes"
> > > > > > > > > > > else
> > > > > > > > > > > me.txt1="No"
> > > > > > > > > > > endif
> > > > > > > > > > > case else
> > > > > > > > > > > if me.cbo2="y" then
> > > > > > > > > > > me.txt1="Yes"
> > > > > > > > > > > else
> > > > > > > > > > > me.txt1="No"
> > > > > > > > > > > endif
> > > > > > > > > > > end select
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > "Pitu" <Pitu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
> > > > > > > > > > >
news:B24DB11D-FBB5-4DAD-A858-0E3ABAFD2C5C@xxxxxxxxxxxxxxxx
> > > > > > > > > > > > Hi,
> > > > > > > > > > > >
> > > > > > > > > > > > I have a bound form with two combobox and one text
box.
> > > now i
> > > > > want
> > > > > > > to
> > > > > > > > > > > > display a certain value yes or no in the text box
based
> > > upon
> > > > > the
> > > > > > > > > > > combination
> > > > > > > > > > > > of values selected from both the comboboxes. how do
i do
> > > that?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
.
- References:
- Re: applying logic in form controls
- From: Rob Oldfield
- Re: applying logic in form controls
- From: Rob Oldfield
- Re: applying logic in form controls
- Prev by Date: Re: WHERE Clause
- Next by Date: Re: Display list of files in a folder on a hard drive in a form
- Previous by thread: Re: applying logic in form controls
- Next by thread: Error 3200 after child record already deleted
- Index(es):
Relevant Pages
|