Input box, pause code for user input

S

Stephm

Hi, there! I am trying to sling a couple bits of code
together, but am not really sure what I'm doing or what
order to place things. I want to have an input box form
open, get user input while pausing main code, and then
use the input. This is what I have- I put a lot of notes
in the code so I hope you can follow along and advise.
Thanks in advance-

Private Sub EmailCommittee_Click()
Dim rst As DAO.Recordset
Dim strTo As String
Dim strOrgParam As String 'name of input box form

'Open OrgParam form and pause running code until input
box form is closed
DoCmd.OpenForm "OrgParam", , , , , acDialog

'Cancel if user clicked the cancel button
If IsLoaded ("OrgParam") = False then
Cancel = True

'Sub procedure to accept values from the input form as
parameter and to set the new module level variable equal
to the value of the parameters. Input box form will call
this sub procedure (OnClose event)
'NO IDEA HOW TO CREATE SUB PROCEDURE

'Make main code pause and wait for user's input
DoCmd OpenForm "OrgParam", acNormal
While SysCmd(asSysCmdGetObjectState, acForm, "OrgParam")
= acObjStateOpen
DoEvents 'do nothing wait for closing
Wend

'Main code to gather data to include
Set rst = CurrentDb.OpenRecordset ("SELECT [Lastlame]
FROM People WHERE [LastName] Is Not Null AND [Member]
=Yes")
With rst
Do Until .EOF
strTo = strTo & ![EmailName] & ";"
.MoveNext
Loop
.Close
End With
strTo = Left(strTo, Len(strTo) - 1)
Set rst = Nothing
'line that would open Outlook to a new message with the
bcc:
'box populated with the list you built in strTo
DoCmd.SendObject acSendNoObject, , , , , strTo, "Last
Name Email"
End Sub
 
S

Stephm

Apologies if this gets posted twice.
Interesting. Thanks for the suggestion. But I want users
to choose from existing data without having to type it
themselves (and get it wrong). Thanks, Stephanie
-----Original Message-----
Can you not just use this?

strOrgParam = inputbox("Type New Data")

Stephm said:
Hi, there! I am trying to sling a couple bits of code
together, but am not really sure what I'm doing or what
order to place things. I want to have an input box form
open, get user input while pausing main code, and then
use the input. This is what I have- I put a lot of notes
in the code so I hope you can follow along and advise.
Thanks in advance-

Private Sub EmailCommittee_Click()
Dim rst As DAO.Recordset
Dim strTo As String
Dim strOrgParam As String 'name of input box form

'Open OrgParam form and pause running code until input
box form is closed
DoCmd.OpenForm "OrgParam", , , , , acDialog

'Cancel if user clicked the cancel button
If IsLoaded ("OrgParam") = False then
Cancel = True

'Sub procedure to accept values from the input form as
parameter and to set the new module level variable equal
to the value of the parameters. Input box form will call
this sub procedure (OnClose event)
'NO IDEA HOW TO CREATE SUB PROCEDURE

'Make main code pause and wait for user's input
DoCmd OpenForm "OrgParam", acNormal
While SysCmd(asSysCmdGetObjectState, acForm, "OrgParam")
= acObjStateOpen
DoEvents 'do nothing wait for closing
Wend

'Main code to gather data to include
Set rst = CurrentDb.OpenRecordset ("SELECT [Lastlame]
FROM People WHERE [LastName] Is Not Null AND [Member]
=Yes")
With rst
Do Until .EOF
strTo = strTo & ![EmailName] & ";"
.MoveNext
Loop
.Close
End With
strTo = Left(strTo, Len(strTo) - 1)
Set rst = Nothing
'line that would open Outlook to a new message with the
bcc:
'box populated with the list you built in strTo
DoCmd.SendObject acSendNoObject, , , , , strTo, "Last
Name Email"
End Sub
.
 

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