Full Version: Update Table Field From Continuos Form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Tiesto_X
Hi,

I have a continuous form and Record Source is an Append table. There is fields: rbID, cBoxPrint, txtTable.

Since append table is filled with 3 different table values rbID can be duplicated, but that is ok since that is just for printing. (its invisible for users)
With cBoxPrint they select what should be printed, and txtTable is the name of table where value came from.

What I need is, when the click cBoxPrint the specific table should be updated, its something like this:

CODE
Dim strSQL As String
Dim tblName As TableDef

tblName.Name = Me!txtTable.Value

strSQL = "UPDATE tblName SET cBoxPrint = True WHERE rbID = " & Me!rbID
DoCmd.RunSQL strSQL


Hope its possible.

Tnx in advance.
theDBguy
Hi,

Not sure what you're really trying to do but try using a String variable instead of a TableDef. For example:

Dim strTableName As String

strTableName = Me.txtTable

strSQL = "UPDATE " & strTableName & " SET...

Just my 2 cents... 2cents.gif
Tiesto_X
Hi,

I did it this way:

CODE
Dim strTableName As String
Dim strSQL As String

strTableName = Me!txtTable.Value

If Me!cBoxPrint = True Then
strSQL = "UPDATE " & strTableName & " SET cBoxPrint = True WHERE rbID = " & Me!rbID
DoCmd.RunSQL strSQL
Else
strSQL = "UPDATE " & strTableName & " SET cBoxPrint = False WHERE rbID = " & Me!rbID
DoCmd.RunSQL strSQL
End If


Tnx for your help. smile.gif

EDIT: But that is what you said. smile.gif
theDBguy
Hi,

Glad to hear you got it sorted out. But, you do realize that you are not actually using the TableDef object anywhere in your code, right?

Good luck with your project.
Tiesto_X
Lol yeah, I'm in hurry and didnt try to realize.

Changed!

Tnx sir!
theDBguy
yw.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.