Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / October 2007

Tip: Looking for answers? Try searching our database.

Update Values from a Userform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gatarossi@ig.com.br - 29 Oct 2007 18:17 GMT
Dear all,

I'm trying to update some information in ms access from a useform in
ms excel. My problem is that I don't known how to do for the vba code
understand the values in my form...

This is the code:

Sub update_tax()

Dim wrkSpace As DAO.Workspace
Dim db As DAO.Database
Dim qryDef As DAO.QueryDef
Dim qryNome As String
Dim strSQL As String
Dim strDB As String

On Error Resume Next
strDB = ThisWorkbook.Path & "\bd.mdb"

Set wrkSpace = Workspaces(0)
Set db = wrkSpace.OpenDatabase(strDB)
qryNome = "qryUpdate_Tax"

db.QueryDefs.Delete qryNome

strSQL = "UPDATE taxa SET tax.tx_dolar = '" & txtTax & "' "
strSQL = strSQL & "WHERE (((tax.period)= '" & txtPeriod & "')) ;"

Set qryDef = db.CreateQueryDef(qryNome, strSQL)

qryDef.Execute

End Sub

Thanks in advance!!!

André.
Bob Phillips - 29 Oct 2007 19:03 GMT
Your SQL would look like

strSQL = "UPDATE tax SET tax.tx_dolar = '" & txtTax.Text & "' " & _
               "WHERE (tax.period= '" & txtPeriod .Text & "') ;"

but this assumes that the code is in the userform, or the form is still in
memory.

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

Dear all,

I'm trying to update some information in ms access from a useform in
ms excel. My problem is that I don't known how to do for the vba code
understand the values in my form...

This is the code:

Sub update_tax()

Dim wrkSpace As DAO.Workspace
Dim db As DAO.Database
Dim qryDef As DAO.QueryDef
Dim qryNome As String
Dim strSQL As String
Dim strDB As String

On Error Resume Next
strDB = ThisWorkbook.Path & "\bd.mdb"

Set wrkSpace = Workspaces(0)
Set db = wrkSpace.OpenDatabase(strDB)
qryNome = "qryUpdate_Tax"

db.QueryDefs.Delete qryNome

strSQL = "UPDATE taxa SET tax.tx_dolar = '" & txtTax & "' "
strSQL = strSQL & "WHERE (((tax.period)= '" & txtPeriod & "')) ;"

Set qryDef = db.CreateQueryDef(qryNome, strSQL)

qryDef.Execute

End Sub

Thanks in advance!!!

André.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.