Multipage Problem- Please Help

S

SaeOngJeeMa

Hi, I have a ComboBox (cboAcctsJmpToCntct) in the first tab of a 4-tab
multipage in a UserForm (ufrmControls). When there is an updated value
entered into that combobox I want Excel open a different tab on the
multipage. See code below. The AfterUpdate event of the combobox launches a
public sub, jumptoNewWshtAndRecord . The problem is that when the sub
executes is doesn't execute the following line of code (no error, it just
basically doesn't do anything when this line executes)
ufrmControls.MultiPage1.Value = 1

I have tried executing this line of code from the Immediate Window when no
subs or functions are running and it opens up the second tab fine. So my
guess is there's a sequence problem in my code- Since, at the time my sub
executes the line of code, I'm currently running code launched by an event in
the first tab maybe it's not letting me open the second tab. It's a Catch-22
because, to my knowledge, there aren't any events outside the first tab that
I can use to trigger the execution of my multipage value change to 1 (second
tab). Any advice would be greatly appreciated. Thanks.

Best Regards,
Dean

************************************************************

'***********Combo Box In MultiPage1 pgeAccts (first tab, Value=0)*********
Private Sub cboAcctsJmpToCntct_AfterUpdate()
If IsNull(ufrmControls.cboAcctsJmpToCntct.Value) Then
'do nothing
Else
Call jumptoNewWshtAndRecord(2, ufrmControls.cboAcctsJmpToCntct.Value)
End If
End Sub


'***********Sub in one of my Public Modules******************
Public Sub jumptoNewWshtAndRecord(bytWorksheet As Byte, lngRefNum As Long)
On Error GoTo Err_jumptoNewWshtAndRecord

Dim lngLastRow As Long
Dim lngJ01 As Long
Dim bytFoundFlag As Byte

'find the last row in the jump to worksheet
lngLastRow = Worksheets(bytWorksheet).Range("A65536").End(xlUp).Row

'loop through the RefNum values from the top row down looking for a match
bytFoundFlag = 0
lngJ01 = 3
Do While ((bytFoundFlag = 0) And (lngJ01 <= lngLastRow))
If Worksheets(bytWorksheet).Cells(lngJ01, 1).Value = lngRefNum Then
bytFoundFlag = 1
Worksheets(bytWorksheet).Select
Worksheets(bytWorksheet).Cells(lngJ01, 1).Select
Worksheets(bytWorksheet).Activate
Select Case bytWorksheet
Case 1 'Accounts
ufrmControls.MultiPage1.Value = 0
Case 2 'Contacts
ufrmControls.MultiPage1.Value = 1
Case 3 'Opportunities
ufrmControls.MultiPage1.Value = 2
Case 4 'Actions
ufrmControls.MultiPage1.Value = 3
End Select
End If
lngJ01 = lngJ01 + 1
Loop

Exit_jumptoNewWshtAndRecord:
Exit Sub
Err_jumptoNewWshtAndRecord:
MsgBox "Sub jumptoNewWshtAndRecord " & Err.Description
Resume Exit_jumptoNewWshtAndRecord
End Sub
************************************************************
 
P

Per Jessen

Hi Dean

Try to add:

Me.Repaint

after

ufrmControls.MultiPage1......

Hopes it helps

Best regards,
Per
 
S

SaeOngJeeMa

Good idea Per, thanks. For some reason I get an error when using that
command. I tried several variations of xxxxxx.Repaint but all of them either
yielded no result or an error ... :-(
Best Regards,
Dean
 
S

SaeOngJeeMa

I think I found a way around this problem but it's definitely a kludge. I
found if I set all of the other Multipage pages' visible properties false,
set the Multipage1.Value equal to the desired number then reset all of the
other Visible properties back to True I get my desired result. Please let me
know if you have a more professional way of doing this. Thanks.

ufrmControls.MultiPage1(0).Visible = False
ufrmControls.MultiPage1(2).Visible = False
ufrmControls.MultiPage1(3).Visible = False
ufrmControls.MultiPage1.Value = 1
ufrmControls.MultiPage1(0).Visible = True
ufrmControls.MultiPage1(2).Visible = True
ufrmControls.MultiPage1(3).Visible = True

Best Regards,
Dean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top