Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When checked, move to table

Status
Not open for further replies.

valgore

Technical User
Nov 12, 2008
180
US
I have a table with a field called CheckBox. it has a checkbox in it. i want to say if it is checked, then import 3 other fields into a different table. so far i have

Code:
Private Sub CheckBox_Click()
On Error GoTo Err_SomeName
DoCmd.RunSQL "INSERT INTO TestCheckboxtable SELECT [AmexCurrent]![Merchant Name/Location] as [Merchant Name/Location], [AmexCurrent]![Carholder Name] as [Cardholder Name], [AmexCurrent]![CheckBox] as [CheckBox] FROM AmexCurrent WHERE Trim([AmexCurrent!CheckBox!] & '')<>''"
Exit_SomeName:
    Exit Sub
Err_SomeName:
     MsgBox Err.Number & Err.Description
     Resume Exit_SomeName
End Sub

but nothing is happening. any help would be appreciated
 
neither worked. i didnt get anything in the table
 
Is the code even being run? What happens if you open a new, blank query and change its SQL view to
Code:
INSERT INTO TestCheckboxtable([Merchant Name/Location],CategoryCode)
SELECT [Merchant Name/Location], CategoryCode FROM AmexCurrent WHERE ChexBox=True

Duane
Hook'D on Access
MS Access MVP
 
im getting a compile error on the second [Merchant Name/Location]
 
valgore,
Post the entire code again so we can take another look at what you are currently running.

Travis

"Why would I ever want to learn about programming when Micorsoft products would be able to handle even the simplest of tasks. Oh...wait a minute...something's wrong with that statement?!
 
In fact, seems you have to provide the REAL names of the fields in the TestCheckboxtable and AmexCurrent tables ...
 
Code:
Private Sub ChexBox_Click()
This event will not do what you want. It shouldn't exist in your module. Period.

Code:
Private Sub ChexBox_ ... k()
You don't want ANY events associated with Chexbox, as above.

You want your triggers to be either a button as DHookom says, or a form event (AfterUpdate, Close ...).

I suggest you get to a tutorial. The best thing I see at the moment is [link href=[URL unfurl="true"]http://www.informit.com/articles/article.aspx?p=21321&seqNum=3[/URL]]here.[/url]

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Thanks Duane! Another clue I should not try a career in web design.

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top