Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialog Box Closes if Presses Enter 1

Status
Not open for further replies.

JeaShe

Programmer
Mar 9, 2004
89
US
I'd like to use a dialog box to obtain up to 28 different pieces of data. We use a scanner here that I've recently found will scan data into a dialog box in Extra.

Problem is everytime a data item is scanned into a cell in the dialog box, it sends the equivalent of an Enter key and the dialog box closes. I need it to stay open until the button is actually clicked. I need to do this in Extra. Any ideas out there???

 
You could try putting another button on the box for the user to enter. After the box closes, check to see which button closed it, if it was the default "OK" button, then reopen with all info re-entered. May take several lines of code, but it should get around your problem.

calculus
 
That's sort of what I thought... that I should loop through until all fields are filled, or until the user clicks a certain button.

Is there a way that each time I loop through I can display the value the user put in the previous loop(s) so it indicates they are already used?
 
Yes, but it's a bit intensive. After every close you'll need to capture all the values in variables, then when you open the box up you'll need to populate all those variables.

calculus
 
I figured that would be the way. I tried it yesterday but couldn't get it to display the variable in a textbox. Could you provide a small example? I'll put my box below.


Begin Dialog newdlg 95, 12, 305, 204, "Zero Rin Not Issued Adcorr Letter"
TextBox 74, 23, 56, 12, .TextBox1
TextBox 185, 25, 80, 12, .TextBox2
TextBox 170, 55, 92, 12, .TextBox3
TextBox 170, 70, 92, 12, .TextBox4
TextBox 170, 85, 92, 12, .TextBox5
TextBox 170, 100, 92, 12, .TextBox6
TextBox 170, 115, 92, 12, .TextBox7
TextBox 170, 130, 92, 12, .TextBox8
TextBox 170, 145, 92, 12, .TextBox9
OkButton 68, 173, 50, 14
Text 5, 10, 211, 12, "Please fill in the boxes with the stated information and click Ok."
CancelButton 165, 173, 50, 14
Text 38, 26, 28, 12, "Corp Id"
Text 142, 27, 36, 12, "RPE Date"
Text 43, 55, 93, 12, "Total Credits and Payments"
Text 43, 70, 48, 12, "Total Allowance"
Text 43, 85, 82, 12, "Total Penalties"
Text 43, 100, 75, 12, "Amount Crdtd Est Allow"
Text 43, 115, 85, 12, "Amt appld Other Bal Due"
Text 43, 130, 51, 12, "Interest Allowed"
Text 43, 145, 47, 12, "Total Allowance"
End Dialog


Dim dMain As newdlg
Dim fmtCorpId As String, string2 As String, string3 As String, string4 As String
Dim string5 As String, string6 As String, string7 As String, string8 As String
Dim string9 As String, string10 As String

nRet = Dialog(dMain)

if nRet = -1 then 'The user pressed OK button
end if
Temp = dMain.TextBox1
Temp = dMain.TextBox2
arg_1 = dMain.TextBox3
arg_2 = dMain.TextBox4
arg_3 = dMain.TextBox5
arg_4 = dMain.TextBox6
arg_5 = dMain.TextBox7
arg_6 = dMain.TextBox8
arg_7 = dMain.TextBox9
end sub
 
I used to call dialogs a bit differently, and I haven't used them in quite awhile (because they are hard to use).

I've adjusted your code to show what I'd suggest. Hopefully you can see what I'm doing and adapt the technique to your code.

Code:
DlgStart:
Begin Dialog newdlg 95, 12, 305, 204, "Zero Rin Not Issued Adcorr Letter"
   TextBox  74, 23, 56, 12, .TextBox1
   TextBox  185, 25, 80, 12, .TextBox2
   TextBox  170, 55, 92, 12, .TextBox3
   TextBox  170, 70, 92, 12, .TextBox4
   TextBox  170, 85, 92, 12, .TextBox5
   TextBox  170, 100, 92, 12, .TextBox6
   TextBox  170, 115, 92, 12, .TextBox7
   TextBox  170, 130, 92, 12, .TextBox8
   TextBox  170, 145, 92, 12, .TextBox9
   Text  5, 10, 211, 12, "Please fill in the boxes with the stated information and click Ok."
    ButtonGroup .Button
   Button  68, 173, 50, 14, "OK"
   Button  165, 173, 50, 14, "Cancel"
   Text  38, 26, 28, 12, "Corp Id"
   Text  142, 27, 36, 12, "RPE Date"
   Text  43, 55, 93, 12, "Total Credits and Payments"
   Text  43, 70, 48, 12, "Total Allowance"
   Text  43, 85, 82, 12, "Total Penalties"
   Text  43, 100, 75, 12, "Amount Crdtd Est Allow"
   Text  43, 115, 85, 12, "Amt appld Other Bal Due"
   Text  43, 130, 51, 12, "Interest Allowed"
   Text  43, 145, 47, 12, "Total Allowance"
End Dialog

    Dim dMain As newdlg
    Dim fmtCorpId As String, string2 As String, string3 As String, string4 As String
    Dim string5 As String, string6 As String, string7 As String, string8 As String
    Dim string9 As String, string10 As String    

        'Reset Dlg box
        dMain.TextBox1 = Temp
        dMain.TextBox2 = Temp1
        dMain.TextBox3 = arg_1
        dMain.TextBox4 = arg_2
        dMain.TextBox5 = arg_3 
        dMain.TextBox6 = arg_4 
        dMain.TextBox7 = arg_5 
        dMain.TextBox8 = arg_6 
        dMain.TextBox9 = arg_7 

        Dialog dmain
        If dmain.button = 0 then Goto StartCode:            '1 for 1st button, 2 for second

        'Get current Dlg State
        Temp = dMain.TextBox1
        Temp1 = dMain.TextBox2
        arg_1 = dMain.TextBox3
        arg_2 = dMain.TextBox4
        arg_3 = dMain.TextBox5
        arg_4 = dMain.TextBox6
        arg_5 = dMain.TextBox7
        arg_6 = dMain.TextBox8
        arg_7 = dMain.TextBox9
        Goto DlgStart:

StartCode:
'Magic code here


End Sub

calculus
 
calculus,

Trying to stay on topic here, but what do you use in lieu of a dialog box?
 
I use VB(A) forms or Excel inputs. Dialog boxes in EB are very clumsy.

calculus
 
Why not have it prompt for each seperately? That way when it sends the enter command it'll close that prompt and the next will appear? After you've collected the data if wanted you could make the orig dialog box appear with all the data populated...
 
One reason I wouldn't want to send the input box over and over is that the techs tend to lose their place. Also, it doesn't seem very professional.
 
What if you function out your dialog and have the values fill-in once initiated?

Code:
Dim complete

Function DlgFunc(identifier$, action, suppvalue)
   Select Case action
   Case 1 'DlgOpened
       DlgText "TextBox1",Temp
       DlgText "TextBox2",Temp
       DlgText "TextBox3",arg_1
       DlgText "TextBox4",arg_2
       DlgText "TextBox5",arg_3
       DlgText "TextBox6",arg_4
       DlgText "TextBox7",arg_5
       DlgText "TextBox8",arg_6
       DlgText "TextBox9",arg_7
   Case 2 'Button/Text Changed
       Select Case identifier$
       Case "ButtonOK"
             complete = true
       End Select
   End Select
End Function

Sub YourDlg
Begin Dialog newdlg 95, 12, 305, 204, "Zero Rin Not Issued Adcorr Letter", .DlgFunc
   TextBox  74, 23, 56, 12, .TextBox1
   TextBox  185, 25, 80, 12, .TextBox2
   TextBox  170, 55, 92, 12, .TextBox3
   TextBox  170, 70, 92, 12, .TextBox4
   TextBox  170, 85, 92, 12, .TextBox5
   TextBox  170, 100, 92, 12, .TextBox6
   TextBox  170, 115, 92, 12, .TextBox7
   TextBox  170, 130, 92, 12, .TextBox8
   TextBox  170, 145, 92, 12, .TextBox9
   OkButton  68, 173, 50, 14, .ButtonOK
   Text  5, 10, 211, 12, "Please fill in the boxes with the stated information and click Ok."
   CancelButton  165, 173, 50, 14
   Text  38, 26, 28, 12, "Corp Id"
   Text  142, 27, 36, 12, "RPE Date"
   Text  43, 55, 93, 12, "Total Credits and Payments"
   Text  43, 70, 48, 12, "Total Allowance"
   Text  43, 85, 82, 12, "Total Penalties"
   Text  43, 100, 75, 12, "Amount Crdtd Est Allow"
   Text  43, 115, 85, 12, "Amt appld Other Bal Due"
   Text  43, 130, 51, 12, "Interest Allowed"
   Text  43, 145, 47, 12, "Total Allowance"
End Dialog
    Dim mydialog as newdlg
    On Error Resume Next
    Dialog mydialog
    If Err <> 102 and complete = false then YourDlg
End If

Sub Main
    complete = false
    YourDlg
End Sub
 
That's an idea... I'll have to try it out. Thanks!
 
JeaShe, if that didn't work I found a way to keep a dialog box open.

Code:
Dim complete

Function DlgFunc(identifier$, action, suppvalue)
   DlgFunc = true
   Select Case action
   Case 1 'DlgOpened
       DlgVisible "ButtonJunk",0
       DlgText "TextBox1",Temp
       DlgText "TextBox2",Temp
       DlgText "TextBox3",arg_1
       DlgText "TextBox4",arg_2
       DlgText "TextBox5",arg_3
       DlgText "TextBox6",arg_4
       DlgText "TextBox7",arg_5
       DlgText "TextBox8",arg_6
       DlgText "TextBox9",arg_7
   Case 2 'Button/Text Changed
       Select Case identifier$
       Case "ButtonOK","ButtonCancel"
             DlgFunc = False
       End Select
   End Select
End Function

Sub YourDlg
Begin Dialog newdlg 95, 12, 305, 204, "Zero Rin Not Issued Adcorr Letter", .DlgFunc
   TextBox  74, 23, 56, 12, .TextBox1
   TextBox  185, 25, 80, 12, .TextBox2
   TextBox  170, 55, 92, 12, .TextBox3
   TextBox  170, 70, 92, 12, .TextBox4
   TextBox  170, 85, 92, 12, .TextBox5
   TextBox  170, 100, 92, 12, .TextBox6
   TextBox  170, 115, 92, 12, .TextBox7
   TextBox  170, 130, 92, 12, .TextBox8
   TextBox  170, 145, 92, 12, .TextBox9
   PushButton 1, 1, 1, 1, "", .ButtonJunk
   PushButton  68, 173, 50, 14, "OK", .ButtonOK
   Text  5, 10, 211, 12, "Please fill in the boxes with the stated information and click OK."
   CancelButton  165, 173, 50, 14, .ButtonCancel
   Text  38, 26, 28, 12, "Corp Id"
   Text  142, 27, 36, 12, "RPE Date"
   Text  43, 55, 93, 12, "Total Credits and Payments"
   Text  43, 70, 48, 12, "Total Allowance"
   Text  43, 85, 82, 12, "Total Penalties"
   Text  43, 100, 75, 12, "Amount Crdtd Est Allow"
   Text  43, 115, 85, 12, "Amt appld Other Bal Due"
   Text  43, 130, 51, 12, "Interest Allowed"
   Text  43, 145, 47, 12, "Total Allowance"
End Dialog
    Dim mydialog as newdlg
    On Error Resume Next
    Dialog mydialog
    If Err = 102 then
'Handle the cancelled window here
    End If
End If

Sub Main
    YourDlg
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top