![]() |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 12:30 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com