InputBox vbCancel

TheToeOfPooh

Active Member
Joined
May 21, 2004
Messages
254
Do you soemtimes wish you hadn't started to improve something? :confused:

I have a series of InputBoxes activated from a "Menu" (Form).
The first asks for the user to enter a filename.
If the vbCancel Button is selected
the Routine will stop by using Exit Sub.

If vbOK is selected
the next InputBox opens and asks for further information e.g. Current Year. And so On.
I am completly stuck as to how I activate an effective response to these further VBOK or vbCancel buttons.

e.g. If the user selects the Cancel Button on the "Year" InputBox
How do I display a suitable MsgBox (Such as "Continue?", vbYesNo)
with options to
vbYes Go to next Inputbox
vbNo Exit Sub

After the Intial Input box which asks for a filename there are 6 of these subsequent Boxes.

Please note this is my first project using VBA with Access so please assume lowest level of understanding when replying with any tips.

Bernard
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Do you soemtimes wish you hadn't started to improve something?
Often :)

If you want more versatility than is available in an Input Box then you Roll your own by creating a custom Form and set its properties to Pop-Up and Modal which will then act like an Input Box

Bet you wished you hadd'nt asked :devilish:

I would not use 7 Pop-ups though! I should think it would soon get tedious to use! Try using 1 form with 7 fields. You can hide fields and things like that to make the form more interactive if you need to. Have a look in help for "custom dialog boxes," shout back when you need some more help :)


HTH

Peter
 
Upvote 0
Peter

A small tree has been used to provide me with the info on creating a custom dialog box - not much to it is there! :eek:

I have made a start - A form and a command button which asks the user for releavnt information (I think?).

I thought a sample of the code I am using might indicate wether I am using appropriate tools for the job:-
Private Sub Cmand40PrintYESTERDAYcsvFile_Click()
'Generate And Transfer data for previous days jobs()

'An automated process using Telnet for extracting data from db2 using a SQL Script
'using SQL Script print_stats.ksh
'from the IBM RS6000 running AIX (UNIX)
'Transfer the file via ftp to directory on my PC
'Which is then imported into Access 2000 as a linked table
'for the Daily Production Management meeting

'Based upon the Print TODAY process
'Created 08-10-03 by Bernard Elgar


Dim strBEFName, strBEChar As String
Dim intBECount, intBEx As Integer
Dim strFromYearDate As String * 4
Dim strFromMonthDate As String * 2
Dim strFromDayDate As String * 2
Dim strToYear As String * 4
Dim strToMonth As String * 2
Dim strToDay As String * 2 'The * 2 = 2 digits long


strBEFName = "*.csv"

'Example septprn05.csv
strClass = vbNullString
strClass = InputBox("Enter YESTERDAYS Date e.g.octprn06.csv.", _
"Enter Yesterdays Date e.g. octprn06", "*.csv")
If StrPtr(strClass) = 0 Then 'IF the vbCancel Button is selected by the user
Exit Sub
Else

'User is asked to define FROM YEAR date
strFromYearDate = InputBox("Enter FROM Year eg 2004.", _
"Enter FROM Year eg 2003", "")

'****NEXT BIT DOESN'T WORK as at 07-10-04****
If (strFromYearDate) = 0 Then 'IF the vbCancelButton is selected by the user
Ans = MsgBox("Continue?", vbYesNo)
'****What am I doing wrong here?****

This is still puzzling me as to how I get around the situation where a user selects the vbCancel Option.

The script then goes on to refer to these values and use them in the associated Telnet and FTP sessions so I am unsure how Dialog Boxes can be reffered to at these later stages in the script. - Aplogise for the lack of mental dexterity.

Bernard
 
Upvote 0
A small tree has been used to provide me with the info on creating a custom dialog box - not much to it is there!

In Access just goto forms and create a new form.

Add (Unbounded) textboxes(or other controls eg comboboxes) to this form for each piece of data you require.

Then add a command button.

In the command button's click event write code that checks the values of the controls on the form for any errors.

If there is anything wrong then can kick the user out of the procedure, back to the form to fix it.

If everything is OK you can proceed with the Telnet and FTP code (which is in the click event as well.

Then finally close the form.

An alternative is that the form passes the values in the textboxes as paramaters to a seperate sub that does the Telner etc stuff.
 
Upvote 0
Peter, Norie

Just to close this off.

I have finally found the following works.
'User is asked to define TO DAY date
strToDay = InputBox("Enter TO Day eg 06 (For 6th).", _
"Enter TO Day eg 06", "")
'Following is all part of same line of code
If vbCancel = MsgBox("Continue? Press OK to proceed or Cancel to Quit.", vbInformation + vbOKCancel + vbDefaultButton1, strFn) Then Exit Sub

I then go onto my next step.

Thank you both for your help.

Bernard
 
Upvote 0

Forum statistics

Threads
1,221,813
Messages
6,162,117
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top