Custom Input Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,

I am stumped. I hate having to open an input box to get user input, and I do it about 30 times in my app, I would much rather open a form with a combo box bound to the data I am asking for, that way they can choose from a list. So I thought I would create a custom Input box

So I have created a form, pop up yes, modal yes with a couple labels and combo box. It has an OK and Cancel button. Then I call a function to open the form and set certain properties, which all works fine. When they push the OK button it send back the choice and if the psuh the cancel button it sends back null. The problem is that I cannot stop execution of my code to wait get the user input. Here functions from the module and the call to open the form, and a function to gather the value..

MODUL
********************************************************************
Public Function gfunOpenCustomInputBox(strTitle As String, strQuestion As String, strComboLabel As String,
strRowSource As String, intColumnCount As Integer,
sngListWidth As Single, strColumnWidths As String

DoCmd.OpenForm ("frmCustomInputBox"

' set all the specifics to the for
With [Forms]![frmCustomInputBox
.Caption = strTitl
.lblQuestion.Caption = strQuestio
.lblComboLabel.Caption = strComboLabe

With .cboDat
.RowSource = strRowSourc
.ColumnCount = intColumnCoun
.ListWidth = sngListWidth * 144
.ColumnWidths = strColumnWidth
End Wit

End Wit


End Functio


Public Function gfunGetCustomInputBoxValue() As Varian

gfunGetCustomInputBoxValue = gvarReturnedValu

End Functio
*****************************************************************
strRowSource = "SELECT UserName, Initials FROM tblUsers

Call gfunOpenCustomInputBox("Choose User", "Please Choose the User to copy.",
"Select User", strRowSource, "3", 2, "1.5 in;1.5in;"

strCopyUserName = gfunGetCustomInputBoxValu

I thought once I opened the modal, pop-up form that it would not execute any code until the form was closed so I could set a value with the OK or cancel buttons and then use another function to retrive the value, but now I can see that is the case. Is there any way to stop the execution so that this can behave just like the inputbox access provides you? I would like to do it all from one function, but the execution proves difficult. Or is there another way to do this? By the way, I use Access 97 SR2. Any comments and ideas would be great!!
 
You need to be specific about opening the form in dialog mode:

DoCmd.OpenForm ("frmCustomInputBox"), WindowMode:=acDialog

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rick Vooys said:
Hello All,

I am stumped. I hate having to open an input box to get user input, and I
do it about 30 times in my app, I would much rather open a form with a combo
box bound to the data I am asking for, that way they can choose from a list.
So I thought I would create a custom Input box.
So I have created a form, pop up yes, modal yes with a couple labels and
combo box. It has an OK and Cancel button. Then I call a function to open
the form and set certain properties, which all works fine. When they push
the OK button it send back the choice and if the psuh the cancel button it
sends back null. The problem is that I cannot stop execution of my code to
wait get the user input. Here functions from the module and the call to open
the form, and a function to gather the value...
MODULE
*********************************************************************
Public Function gfunOpenCustomInputBox(strTitle As String, strQuestion As
String, strComboLabel As String, _
strRowSource As String, intColumnCount As Integer, _
sngListWidth As Single, strColumnWidths As String)


DoCmd.OpenForm ("frmCustomInputBox")

' set all the specifics to the form
With [Forms]![frmCustomInputBox]
.Caption = strTitle
.lblQuestion.Caption = strQuestion
.lblComboLabel.Caption = strComboLabel

With .cboData
.RowSource = strRowSource
.ColumnCount = intColumnCount
.ListWidth = sngListWidth * 1440
.ColumnWidths = strColumnWidths
End With

End With


End Function



Public Function gfunGetCustomInputBoxValue() As Variant

gfunGetCustomInputBoxValue = gvarReturnedValue

End Function
******************************************************************
strRowSource = "SELECT UserName, Initials FROM tblUsers"

Call gfunOpenCustomInputBox("Choose User", "Please Choose the User to copy.", _
"Select User", strRowSource, "3", 2, "1.5 in;1.5in;")

strCopyUserName = gfunGetCustomInputBoxValue

I thought once I opened the modal, pop-up form that it would not execute
any code until the form was closed so I could set a value with the OK or
cancel buttons and then use another function to retrive the value, but now I
can see that is the case. Is there any way to stop the execution so that
this can behave just like the inputbox access provides you? I would like to
do it all from one function, but the execution proves difficult. Or is there
another way to do this? By the way, I use Access 97 SR2. Any comments and
ideas would be great!!
 
Back
Top