VBA Forms Problem

Computer builds, hardware and software discussion or troubleshooting, including peripherals. Essentially a general place to talk about desktop computers.
Locked
Electric Ant
Posts: 23
Joined: Fri Mar 26, 2004 8:22 am

VBA Forms Problem

Post by Electric Ant »

Any help gratefully received.... I'm not a programmer but the people I work with think I am the IT guru which is quite scary. I must fake it really well.

OK don't laugh at me.......it's VBA.....What I've got is an Excel spreadsheet. A MultiPage Form pops up to get the user to fill in some data. On each page there's a ? button which pops up another multipage containing help for each page because I'm nice like that. When you've finished with the help, click the close button to carry on filling in the original MultiPage Form.

This works absolutely fine for most users except on two laptops. When they Close the help MultiPage they get kicked back to the start of the first page of the Main MultiPage and everthing they put in is wiped out. I've got a bit of code that resets everything on the UserForm_Activate event to make sure when people first open the form they start at the beginning and work their way through but I don't understand why for two people the main form gets reactivated when they close help. I got their machine and stepped through the code and it worked fine, but doesn't in run time....

We should all have the same set up on our laptops so not sure why just these two. If it was just one I would think it was the them...

I'm not doing anything ninja as people scare easily......

In the MainForm Code I have for each page......

Private Sub pg2CommandButton_help_Click()
helppagenumber% = 0
HelpForm.Show
End Sub

In the HelpForm I have.........

Private Sub pg5CommandButton_helpclose_Click()
helpclose
End Sub

...and.......

Sub helpclose()
Application.ScreenUpdating = False
mysheet.Select
HelpForm.Hide
Unload HelpForm
End Sub

:grade11math:

I'd like to know why it doesn't work even if it is just these people because their set up is causing it....No idea where to look. Tried an online search but can't find anything helpful.

Please help!!


Archived topic from Iceteks, old topic ID:2243, old post ID:19073
User avatar
Red Squirrel
Posts: 29209
Joined: Wed Dec 18, 2002 12:14 am
Location: Northern Ontario
Contact:

VBA Forms Problem

Post by Red Squirrel »

lol I sort of feel bad lot of people are posting programming questions but none of us know lot of languages. I know a bit of C++ and more php only. Hopefully someone around here knows VB...

Archived topic from Iceteks, old topic ID:2243, old post ID:19092
Honk if you love Jesus, text if you want to meet Him!
Fat Cat
Posts: 16
Joined: Wed Mar 31, 2004 8:33 pm

VBA Forms Problem

Post by Fat Cat »

Your syntax looks fine to me.

When closing the Help Form in the helpclose subroutine, you should automatically go back to the same Excel sheet you launched from if you leave out the mysheet.Select command.

This command is normally used to jump to a different sheet inside the Excel workbook. If you don't specify a new sheet location to go to, the flow control should automatically take you back to the sheet and position you launched the HelpForm from and leave any data entered on the sheet intact.

Alternatively use the Visible command rather than select
ie: mysheet.Visible = xlSheetVisible

You could issue a save command before launching the help form to at least preserve the data you have, but this does add a noticable delay while the disk file is written.

ie:
Excel.ThisWorkbook.Save




Archived topic from Iceteks, old topic ID:2243, old post ID:19205
Electric Ant
Posts: 23
Joined: Fri Mar 26, 2004 8:22 am

VBA Forms Problem

Post by Electric Ant »

Thanks Fat Cat....

yeah you're right ...I don't think I need the mysheet.select as you just view the help pages so the active worksheet shouldn't change....laziness on my part as I just nicked code from somewhere else in the prog....

I'm still completely baffled why some users get kicked back to the start....I'm wondering if it is the unload command???


and Red...don't feel bad, I don't know much VB either. :dosgonebad: I just fiddle and hope for the best...

Archived topic from Iceteks, old topic ID:2243, old post ID:19206
Fat Cat
Posts: 16
Joined: Wed Mar 31, 2004 8:33 pm

VBA Forms Problem

Post by Fat Cat »

where I come from VB is a cold fizzy beer so perhaps I know more than I think (although thinking normally ceases after a few).

Archived topic from Iceteks, old topic ID:2243, old post ID:19221
Locked