Re: cmdFind_Click

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jim Carlock (anonymous_at_10.10.com)
Date: 02/24/04


Date: Tue, 24 Feb 2004 14:10:55 -0500

For some reason, the error is occuring in another routine and
being thrown back out to the cboFindMatl_Click() routine.

Must be one of the routines that don't have any error trapping
within them.

Randy Birch mentioned something about this in another
group of messages. I'm seeing it now.

-- 
Jim Carlock
http://www.microcosmotalk.com/
Post replies to the newsgroup.
"Bob Butler" <tiredofit@nospam.com> wrote in message
news:%23QXfoQw%23DHA.808@TK2MSFTNGP12.phx.gbl...
"Jim Carlock" <anonymous@10.10.com> wrote in message
news:eQ16UHw%23DHA.712@tk2msftngp13.phx.gbl
> I'm using a cmdFind_Click.
>
> It's a command button, TypeName(cmdFind) returns "CommandButton".
> VarType(cmdFind) returns 11 which is a Boolean type.
>
> I'm testing this as the form is loading up, and I'm getting errors as
> follows:
>
> ERROR#: 91
> Object variable or With block variable not set
on what statement? Your probelm is not clear.
> I've seen this error in the past and I think it has something to do
> with the fact that the cmdFind button isn't completely instantiated.
> I put a Me.Show in the Form_Load event but that doesn't seem to
> instantiate the button either.
by the time Form_Load runs the command buttons are there.  Data controls may
not be connected and ready for use and but command buttons are available.
> I use the cmdFind_Click call just fine after the form is fully in
> place.
>
> Basically it all looks like this:
>
> Private Sub cmdFind_Click()
>     'routines to search the datacontrol / fill text boxes, etc
> End Sub
>
> Private Sub cmbFindMatl_Click()
>     On Error Goto LocalErr
>     cmdFind_Click
rather than call an event routine directly it's better IMO to use
  cmdFind.Value=True
or, even better, move the code to a common routine that is called from both
cmdFind_Click and cmbFindMatl_Click
>     Exit Sub
> LocalErr:
>     MsgBox "ERROR # " & CStr(Err.Number) & vbCrLf & Err.Description
>     Err.Clear
> End Sub
>
> Private Sub Form_Load()
>     Me.Move 0, 0
>     Me.Show
>     subFillCombo
>     subConnectDataControl
I suspect that the data control is your real problem
>     '... some other irrelevant stuff
> End Sub
>
> The only thing popping into my head is to set up a Boolean variable
> that is form-wide, that gets set to True at the end of the Form_Load.
you may also want to use form_activate instead of form_load and add code to
prevent it from running twice
> Wondering if anyone has another suggestion?
> And also wondering why cmdFind is returning itself as a Boolean
> variable type.
The default property of the command button is probably what you are seeing
> You can duplicate the VarType issue by putting a command button
> on an empty form and for the code, set it up as follows:
>
> Private Sub Command1_Click()
>     MsgBox CStr(VarType(Command1))
> End Sub
>
> Let me know if it's occuring on your machine as well! I keep
> wondering, "What's wrong with my system?"
I get:  11
-- 
Reply to the group so all can participate
VB.Net... just say "No"

Quantcast