 |
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

March 15th, 2005, 02:42 PM
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Grabbing Value From Textbox in subform
Hello All,
I have a subform1, with a textbox1. I want to capture, and save the value that gets input into the textbox, so that I can send the value via email to Support Staff.
I'm trying to accomplish this by running a macro in the AfterUpdate Event. The email works great by I have no idea how to get capture the value.
Brian
|

March 15th, 2005, 02:46 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Brian,
What does your macro do? Can it be converted to vb? If you use an event procedure (code instead of a macro), you will be able to use the value of your text box. Let me know.
Kevin
dartcoach
|

March 15th, 2005, 02:52 PM
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Hi Kevin,
I was trying a runsql cmd, with the following syntax
INSERT INTO bph_tbl select from form!subform1.textbox1
The email works, though it wasn't sending anything.
Brian
|

March 15th, 2005, 03:00 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Brian,
Change your after update to to an event procedure. Your code should look like this:
Dim Sql, strquote as string
strquote = """"
sql = "Insert into bph_tbl (Text) select " _
& strquote _
& me.subform1.form.textbox1 _
& strquote _
& " as expr1;"
docmd.runsql sql
Have you checked the table your inserting to, to see if your textbox is actually getting populated?
Kevin
dartcoach
|

March 15th, 2005, 03:14 PM
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Kevin,
I'm checking that now. I'm erring out the last line, & " as expr1;"
Let me double check and see what I did wrong.
Brian
|

March 15th, 2005, 03:40 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Brian,
When I have a problem with sql syntax, I comment out the docmd.runsql line and put in:
msgbox sql
This shows me the actual sql statement. Check it to make sure that it's valid. Be especially watchful of the spaces. If you forget a space or have an extra one, it will cause the statement not to be understood.
Kevin
dartcoach
|

March 15th, 2005, 03:46 PM
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Runtime error 2465
MA can't find the field "|" refered to in your expression.
when i go into debug mode the arrow points right at this expression
& " as expr1;"
This is what I have in there to reflect the names in the database. And yes, they designed it with spaces in form name.
Dim Sql, strquote As String
strquote = """"
Sql = "Insert into bph_tbl (Text) select " _
& strquote _
& Me.[table1 subform].Form.ComputerName _
& strquote _
& " as expr1;"
|

March 15th, 2005, 03:56 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Brian,
Cut and paste this in:
Dim Sql, strquote As String
strquote = """"
Sql = "Insert into bph_tbl (Text) select " _
& strquote _
& Me.table1_subform.Form.ComputerName _
& strquote _
& " as expr1;"
this line Me.table1_subform.form.computername -
What's the name of your main form and the name of your subform?
me. - this identifies the main form
.table - identifies the subform
.form - says its a subform
.computername - the field on the subform
Kevin
dartcoach
|

March 15th, 2005, 04:13 PM
|
Friend of Wrox
|
|
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
[table1 subform] is the name of the subform.
computername is the name of the textbox on the subform
name of the main form is Primary
thanks, bph
|

March 15th, 2005, 04:17 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
In that case your syntax should look like this:
Dim Sql, strquote As String
strquote = """"
Sql = "Insert into bph_tbl (Text) select " _
& strquote _
& Me.table1_subform.Form.ComputerName _
& strquote _
& " as expr1;"
Try that.
Let me know.
Kevin
dartcoach
|
|
 |