views:

130

answers:

1

I have a project with MS-Access (Front End) + MySQL (BackEnd)

There are STATUS and DEL_FLG columns in a table called TB_STATUS

strSQL = "SELECT * FROM TB_STATUS"
rs.Open strSQL, cn, adOpenKeyset, adLockOptimistic
If rs.RecordCount <> 0 Then
    Set Form.Recordset = rs
    rs.Close
End If

User Interface is

|text||valid||invalid|

A value of DEL_FLG is invalid with an invalidity button in the case of 0, and a value of DEL_FLG wants to let you invalidate an effective button in the case of 1,

How to do it?

A: 

Assuming that your button is called myButton, I think what you want to do something like this:

strSQL = "SELECT * FROM TB_STATUS"
rs.Open strSQL, cn, adOpenKeyset, adLockOptimistic
If rs.RecordCount <> 0 Then
    Set Form.Recordset = rs

    if rs("DEL_FLG") = 0 then
        me.myButton.enabled = false
    else
        me.myButton.enabled = true    
    end if
    rs.Close
End If

Note: I'm not sure how MySQL store booleans (0, -1) or (0, 1) => (true, false), so some playing might be necessary.

CodeSlave
MySQL lacks a dedicated Boolean field, so it's just TINYINT(1). Access has no problem with this if you bind checkboxes to the field (the checkbox can be two-state or three-state, so handles Nullable Boolean). And if you test for False or Not False, you'll always be safe no matter what the value any particular database uses for True.
David-W-Fenton
"Nullable Boolean" = oxymoron.
onedaywhen