Inputbox question.

G

Guest

Is it possible for the popup input box to have more than 1 questions in one
prompt instead of clicking one then the other one pops up again etc?

Here is a sample code ---- Instead of the 2 inputbox popping up, i would
like to have only one inputbox with the 2 questions that the user can fill in
all at once before clicking ok?


Private Sub TRAINING_AfterUpdate()
Dim strsql As String, strValue As String, strval As String, NewID As
Integer, Response As Integer
If TRAINING = 0 Then
strValue = InputBox("What value do you want to add to the list?",
"Input Value")
strval = InputBox("what is your credit?", "Input value")
If strValue <> "" Then
strsql = _
"Insert Into tbxTraining ([Training],[credits]) values ('" &
strValue & "'" & "," & strval & ")"

'MsgBox strsql
CurrentDb.Execute strsql, dbFailOnError
Response = acDataErrAdded
NewID = DLookup("[TrainingID]", "tbxTraining", "Training = '" &
strValue & "'")
Me.TRAINING.Requery
Me.TRAINING = NewID
End If
End If
End Sub
 
F

fredg

Is it possible for the popup input box to have more than 1 questions in one
prompt instead of clicking one then the other one pops up again etc?

Here is a sample code ---- Instead of the 2 inputbox popping up, i would
like to have only one inputbox with the 2 questions that the user can fill in
all at once before clicking ok?

Private Sub TRAINING_AfterUpdate()
Dim strsql As String, strValue As String, strval As String, NewID As
Integer, Response As Integer
If TRAINING = 0 Then
strValue = InputBox("What value do you want to add to the list?",
"Input Value")
strval = InputBox("what is your credit?", "Input value")
If strValue <> "" Then
strsql = _
"Insert Into tbxTraining ([Training],[credits]) values ('" &
strValue & "'" & "," & strval & ")"

'MsgBox strsql
CurrentDb.Execute strsql, dbFailOnError
Response = acDataErrAdded
NewID = DLookup("[TrainingID]", "tbxTraining", "Training = '" &
strValue & "'")
Me.TRAINING.Requery
Me.TRAINING = NewID
End If
End If
End Sub


I suppose, in theory, you could enter 2 different data values,
separated by a specific character.
In my example the vertical line:

strAnswer = InputBox("what is your credit?"|"Input value")
Type the 2 answers separated with a |.
Answer1|Answer2
Then parse the string using
strValue1 = Left(strAnswer,inStr(strAnswer,"|")-1)
for the First Answer then
strValue2 = Mid(strAnswer,InStr(strAnswer,"|")+1)
to get the Second Answer, but it's more work than it's worth plus it
leaves the answers open to mistyping, a missing value entry, as well
as incorrect datatype entry.

A better solution would be to use an unbound form with 2 unbound text
controls.
Add a command button and code it's click event:
Me.Visible = False
Then you can use logic on the form to verify the correct kind of
entry, then read the result using VBA.

DoCmd.Openform "frmNewValue", , , , , acDialog
strValue1 = forms!frmNewValue!ControlName1
strValue2 = forms!frmNewValue!ControlName2
DoCmd.Close acForm, "frmNewValue"

then use these strings in your SQL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top