Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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
 
Old March 15th, 2005, 02:42 PM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default 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


 
Old March 15th, 2005, 02:46 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old March 15th, 2005, 02:52 PM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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

 
Old March 15th, 2005, 03:00 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old March 15th, 2005, 03:14 PM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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



 
Old March 15th, 2005, 03:40 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old March 15th, 2005, 03:46 PM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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;"

 
Old March 15th, 2005, 03:56 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old March 15th, 2005, 04:13 PM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default

[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
 
Old March 15th, 2005, 04:17 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Grabbing a section of a sound file BrianWren Pro VB 6 0 January 3rd, 2008 04:21 PM
Grabbing form variables jroxit Classic ASP Basics 5 June 18th, 2007 05:08 PM
Grabbing user login info Quick209 ASP.NET 2.0 Basics 1 May 12th, 2006 07:06 PM
Grabbing data from a WebTable Ahrenl Excel VBA 1 May 24th, 2005 12:34 PM
Grabbing URL aingalsbe PHP How-To 1 April 5th, 2004 05:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.