Check box using data coming from user input

Leen

Registered User.
Local time
Today, 21:15
Joined
Mar 15, 2007
Messages
56
Hi,

I made a form with several checkboxes. The aim is that a user can vink/devink the checkbox and that, in case a checkbox is vinked, I can see that using code.

I was trying by using the 'Onclick' event but I can't get the possibility to register in my code wheter or not the checkbox is clicked?

For example, the name of a checkbox is "Landuse". The user can check/uncheck this. In my code, I'd like to know wheter the status of the check box is yes or no. (As it is an unbound checkbox, I can't find the value True/False)

I think it can't difficult but in some way I can't find it..
Thanks a million!

Leen
 
which code are u trying to see the check box from?

if me.landuse = true then

is how u would see if its true
 
If Me.Checkbox = True Then
 
I was trying by using the 'Onclick' event but I can't get the possibility to register in my code wheter or not the checkbox is clicked?
Use the AfterUpdate event of the checkbox
(As it is an unbound checkbox, I can't find the value True/False)
If it is unbound then what happens when they move from that record and come back, it isn't going to have the value they selected.
 
I'm don't understand exactly, my problem is the following :

My form looks like this:
*some checkboxes
*at the end a command button named "GO"

The aim of my code:
If the user has vinked a checkbox (example, a checkbox named "Checkadmin"), then, when he clicks on the command button beneath, the table "ADMIN" has to be imported (using DoCmd.TransferDatabase)

What I did:
*Using the Commandbutton, I've put on my code in "Microsoft Office Class Objects" under "form":

Code:
Public Sub Go_Click()
ActionsQC
End Sub

*In my code in a "module", I put:

Code:
Sub ActionsQC()
Public Checkadmin As CheckBox

If Me.Checkadmin = True Then
    DoCmd.TransferDatabase acImport, "dBASE IV", PathSource_ADMIN, acTable, "ADMIN", "ADMIN", False
End If

However, I get the error: "Invalid use of keyword Me". Do I also have to use an "After update" event on the checkbox?

I'm not familiar with using this method, can someone help me solving this?
 
OK, the invalid use of the keyword ME is that you can't use "ME" in a standard module, only in a form's module.

So, the way around that is to do this. Change your sub to:
Code:
Public Sub ActionsQC(strForm as String) 
Public Checkadmin As CheckBox

If Forms(strForm).Checkadmin = True Then
    DoCmd.TransferDatabase acImport, "dBASE IV", PathSource_ADMIN, acTable, "ADMIN", "ADMIN", False
End If

and change the call to:
Code:
Private Sub Go_Click()
   ActionsQC Me.Name
End Sub
 
Thanks! Using your code I simplified it (importing the tables right away in the form). My final code, which works :):
"Main" = name of my form
"CheckRailways" = Name of the checkbox

Code:
Public Sub import_Click()

If Forms(Main).CheckRailways = True Then
    PathSource = PathSource_RAILWAYS
    NameInput = "RAILWAYS"
    NameOutput = "RAILWAYS"
    DoCmd.TransferDatabase acImport, "dBASE IV", PathSource, acTable, NameInput, NameOutput, False
End If

End Sub

Thanks again for your help!
 

Users who are viewing this thread

Back
Top Bottom