 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA 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
|
|
|
|

May 22nd, 2006, 10:36 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Moving input from textbox to field
Hi All,
I'm new to VBA (access)and I'm having a problem with my program.
I have a form that has 3 textboxes and a button. When the button gets clicked I want the user input from the three textboxes to go to their corresponding fields on a table.
the textboxes are ShtNbr,JitlDue, and JITL
the field names are Sheet Number, Jitl due date, and Jitl number
Thanks for any help,
Dave
|
|

May 22nd, 2006, 10:39 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Why are you using an unbound form for this? If the form was bound to the table, it would be inserted automatically as it was entered. What tasks are you doing between entry and posting that prevents you fom binding?
You need to drop a button on the form with some text indicating it will save the entered data. Then on the button's On Click event, you need to open a recordset on the table where you want the data entered, then use the AddNew and Update methods to post the data to a new record.
What part do you need help on?
mmcdonal
|
|

May 22nd, 2006, 10:41 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Also, are you using ADO or DAO? I would recommend DAO if the database is all Access.
mmcdonal
|
|

May 22nd, 2006, 10:47 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for replying,
The form is actually bound and does transfer the input from the textboxes to the fields. But, the enter key has to be pressed before the button will work and I'm trying to get around that, just to make the form more user friendly. When the enter key is hit the textboxes are cleared and the input goes to the fields in the table. Then when the button is hit the fields are written to a text document.
|
|

May 22nd, 2006, 10:48 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'm using DAO.
|
|

May 22nd, 2006, 11:05 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
SO the button you have on the form moves data from the database to a text file?
It sounds like you have the following functions:
1. Data entry on the bound form works as normal, and when the enter key is hit, the form moves to the next (new) record. (This gives the appearance of the text boxes being cleared.)
2. When a button is clicked, data is written to a text file. Is THIS the process you want to automate when the form moves to the next (new) record?
It doesn't sound like you "want the user input from the three textboxes to go to their corresponding fields on a table," but you want the data from the text boxes to be "written to a text document." Is that correct?
Thanks.
mmcdonal
|
|

May 22nd, 2006, 11:50 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I do want the data to go to the table as well as the text document b/c the table data is saved where as the document is sent as an
e-mail.
This is the code that is with the button.
Dim stDocName As String
stDocName = "ExportNewAGINtbl_mcr"
DoCmd.RunMacro stDocName
And (I believe) this is the code that takes the data to the text doc.
Like I said I'm new to vba, so I'm trying to get a feel for how this program works. I'm not the original author, so I've had to study on it quite a bit.
Private Sub Command11_Click()
On Error GoTo Err_Command11_Click
WinWord.exe "C:\Documents and Settings\jtrent\My Documents\Tricia\Envelope\envelope.txt"
Call Shell(stAppName, 1)
Exit_Command11_Click:
Exit Sub
Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click
End Sub
That does make sense that the enter key makes it go to the next record.
But, is there any way that I could tie that process to the button instead of the enter key.
Basically, I don't want the enter key to do anything. After the data is input I want the button to write the data to the table fields and to the text doc.
Thanks
-Dave
|
|

May 24th, 2006, 11:33 AM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OK I figured it out.
DoCmd.Requery
i hate how simple stuff is.
|
|
 |