Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Newbie form show prob

Hello All,

Just starting this vba thing and I've hit a prob. I've got a sub that asks
some questions and if the response is correct it should open a userform for
further data:

msg = MsgBox("Are the savings over £6000?", vbYesNo)
If Response = vbYes Then 'the user chose yes
Tariff_HB.Show 'bring the form on screen
End If
If Response = vbNo Then 'the user chose no
Exit Sub 'get out of it

Which all seems to look OK (to me!) but the form doesn't load...

What's wrong?

Thanks in advance.

Martin


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Newbie form show prob

Martin,

Your code should be :

Response= MsgBox("Are the savings over £6000?", vbYesNo)

HTH

"Martin" wrote:

Hello All,

Just starting this vba thing and I've hit a prob. I've got a sub that asks
some questions and if the response is correct it should open a userform for
further data:

msg = MsgBox("Are the savings over £6000?", vbYesNo)
If Response = vbYes Then 'the user chose yes
Tariff_HB.Show 'bring the form on screen
End If
If Response = vbNo Then 'the user chose no
Exit Sub 'get out of it

Which all seems to look OK (to me!) but the form doesn't load...

What's wrong?

Thanks in advance.

Martin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Newbie form show prob

You're not putting the return value from MsgBox into your Response
variable, so you'll never have Response=vbYes.

Try:

Dim Response As Long
Response = MsgBox("Are the savings over £6000?", vbYesNo)
If Response = vbNo Then Exit Sub
Tariff_HB.Show




In article ,
"Martin" wrote:

Hello All,

Just starting this vba thing and I've hit a prob. I've got a sub that asks
some questions and if the response is correct it should open a userform for
further data:

msg = MsgBox("Are the savings over £6000?", vbYesNo)
If Response = vbYes Then 'the user chose yes
Tariff_HB.Show 'bring the form on screen
End If
If Response = vbNo Then 'the user chose no
Exit Sub 'get out of it

Which all seems to look OK (to me!) but the form doesn't load...

What's wrong?

Thanks in advance.

Martin

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Newbie form show prob

To add to what Toppers wrote, it's often desirable to make forms modal.
a more formal way to write the sub would be:

Dim frm As Tariff_HB

If MsgBox("Are the savings over £6000?", vbYesNo) = vbYes Then
Set frm = New Tariff_HB
Tariff_HB.Show vbModal
Set frm = Nothing
End If

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Newbie form show prob

Hello,

Ah, it all becomes clear! Many thanks to you both you've been very helpful.

Martin


wrote in message
ups.com...
To add to what Toppers wrote, it's often desirable to make forms modal.
a more formal way to write the sub would be:

Dim frm As Tariff_HB

If MsgBox("Are the savings over £6000?", vbYesNo) = vbYes Then
Set frm = New Tariff_HB
Tariff_HB.Show vbModal
Set frm = Nothing
End If


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to make a list/form Newbie!!!!! wanderer Excel Discussion (Misc queries) 1 October 20th 06 05:27 AM
Show Data Form David Holtby[_2_] Excel Programming 0 October 20th 04 01:48 PM
Help! Animated gif-image in form does not show animation when form loaded JoCa Excel Programming 4 September 23rd 04 07:43 PM
Trouble with filtering form - newbie ryssa Excel Programming 1 June 22nd 04 04:33 AM
Show' Read Only' On A Form Dave[_18_] Excel Programming 1 July 30th 03 12:29 AM


All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"