Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Prompt User for value

 
   Database Help (Home) -> MS Access RSS
Next:  SendObject method not available error  
Author Message
auujxa2 via AccessMonster

External


Since: Dec 31, 2008
Posts: 2



(Msg. 1) Posted: Wed Dec 31, 2008 3:25 pm
Post subject: Prompt User for value
Archived from groups: microsoft>public>access (more info?)

I have SQL append to a table when a button is clicked. But I can't get the
final field to prompt the user properly for a value. I'm trying to append
values from a multi select list, and have the user enter a different value
for each selection. I've tried so many different combinations for syntax
issues at the end of the SQL. The code works for the first 3 fields if I
remove the fourth.

Dim strSQL As String
Dim varItem As Variant
Dim frm As Form, ctl As Control
Set frm = Forms!frmMaintenance
Set ctl = frm!lstAvailableFixtures
Dim myCode As String

myCode = InputBox("Please enter the count for fixture.", "Fixture Count", "0")


DoCmd.SetWarnings False

For Each varItem In Me.lstAvailableFixtures.ItemsSelected

strSQL = "INSERT INTO [SpringUnitCapacities_Tbl] (Store, DeptNo,
FixtureNo, Quantity)" & _
"SELECT " & Me.cboAddNewStore & "," & Me.cboAddNewStoreDept & ",
""" & ctl.ItemData(varItem) & ", """ & myCode & """"

DoCmd.RunSQL strSQL

Next varItem

Thank you in advance, and happy new year!

--
Laser

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access/200812/1

 >> Stay informed about: Prompt User for value 
Back to top
Login to vote
auujxa2 via AccessMonster

External


Since: Dec 31, 2008
Posts: 2



(Msg. 2) Posted: Wed Dec 31, 2008 4:35 pm
Post subject: Re: Prompt User for value [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Ideally, I'd like to have each fixture name included so the user knows which
fixture they're being prompted for. (fyi, all fields are text)

here's my updated code, but I'm getting a missing operator syntax error.

Dim strSQL As String
Dim varItem As Variant
Dim frm As Form, ctl As Control
Set frm = Forms!frmMaintenance
Set ctl = frm!lstAvailableFixtures
Dim myCode As String

DoCmd.SetWarnings False

For Each varItem In Me.lstAvailableFixtures.ItemsSelected

myCode = InputBox("Please enter the count for " & ctl.ItemData(varItem))

strSQL = "INSERT INTO [SpringUnitCapacities_Tbl] (Store, DeptNo,
FixtureNo, Quantity)" & _
"SELECT " & Me.cboAddNewStore & "," & Me.cboAddNewStoreDept & ",
""" & ctl.ItemData(varItem) & ",""" & myCode & """"

DoCmd.RunSQL strSQL

Next varItem

auujxa2 wrote:
>I have SQL append to a table when a button is clicked. But I can't get the
>final field to prompt the user properly for a value. I'm trying to append
>values from a multi select list, and have the user enter a different value
>for each selection. I've tried so many different combinations for syntax
>issues at the end of the SQL. The code works for the first 3 fields if I
>remove the fourth.
>
>Dim strSQL As String
>Dim varItem As Variant
>Dim frm As Form, ctl As Control
>Set frm = Forms!frmMaintenance
>Set ctl = frm!lstAvailableFixtures
>Dim myCode As String
>
>myCode = InputBox("Please enter the count for fixture.", "Fixture Count", "0")
>
>DoCmd.SetWarnings False
>
>For Each varItem In Me.lstAvailableFixtures.ItemsSelected
>
> strSQL = "INSERT INTO [SpringUnitCapacities_Tbl] (Store, DeptNo,
>FixtureNo, Quantity)" & _
> "SELECT " & Me.cboAddNewStore & "," & Me.cboAddNewStoreDept & ",
>""" & ctl.ItemData(varItem) & ", """ & myCode & """"
>
> DoCmd.RunSQL strSQL
>
>Next varItem
>
>Thank you in advance, and happy new year!
>

--
Laser

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access/200812/1

 >> Stay informed about: Prompt User for value 
Back to top
Login to vote
John W. Vinson

External


Since: Nov 16, 2007
Posts: 1727



(Msg. 3) Posted: Thu Jan 01, 2009 5:09 pm
Post subject: Re: Prompt User for value [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 31 Dec 2008 20:34:50 GMT, "auujxa2 via AccessMonster.com"
wrote:

>deally, I'd like to have each fixture name included so the user knows which
>fixture they're being prompted for. (fyi, all fields are text)
>
>here's my updated code, but I'm getting a missing operator syntax error.

The Insert .... SELECT syntax is for inserting data from a query into a table.
Here you're inserting specific single values (which may be an excessively
complicated way to do things; why not use a bound form!?), so you need the
VALUES keyword and another pair of parentheses. You also need quotemarks
around all of the values to be inserted into Text fields. Try

myCode = InputBox("Please enter the count for " & ctl.ItemData(varItem))

strSQL = "INSERT INTO [SpringUnitCapacities_Tbl] (Store, DeptNo,
FixtureNo, Quantity)" & _
"VALUES( '" & Me.cboAddNewStore & "','" & Me.cboAddNewStoreDept & "',
'" & ctl.ItemData(varItem) & "','" & myCode & "');"

This will expand into something like



INSERT INTO [SpringUnitCapacities_Tbl]
(Store, DeptNo, FixtureNo, Quantity)
VALUES( 'StoreName','Housewares','Skillet','HW3123');

If any of the store names, departments or items may contain apostrophes,
replace the ' delimiters in the strSQL expression with two consecutive " marks
(double doublequotes in a doublequote delimited string will become a single
doublequote).
--

John W. Vinson [MVP]
 >> Stay informed about: Prompt User for value 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Move files and prompt user if overwriting existing file - I have the following code which is using the copy and kill command to move files from one folder to another. It worked pretty good for private use, but now I need it in the office and I would need to prompt the user in case the file already exists. My..

move files and prompt user if file already exists in targe.. - I have the following code that moves files between folders. Unfortunately, already existing files get overwritten if the new filename is the same. Is there a way to prompt the user in case the file would already exist and to abort the copy kill operation...

Yes or No Prompt - I currently have a data entry from only set up with a “Confirm” button that the person must press after data has been entered to check that the required data has been into the form. For the confirm button to work each of the required fields is..

Prompt in a Report - I have a report based on a query that prompt the user for the Relationship Manager name when opened. When I run the query by itself there is only one prompt, however when I open the report, the same prompt comes up 3 different times. I figure that thi...

The @ sign in MsgBox prompt? - If MsgBox(sMyCaption & " is already open@" _ & "Do you want to open a second instance of this database?@", _ vbYesNo Or vbQuestion Or vbDefaultButton2) = vbYes Then Exit Function What's the purpose behind the @ si...
   Database Help (Home) -> MS Access All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]