2014-11-08 44 views
0

我想知道爲什麼在第一次執行時單擊yes/no框時生成的以下代碼不起作用。一旦點擊它,代碼就會被執行,但不會確認複選框已被選中,而選中的複選框卻留下了我,但沒有得到正確的結果。取消選擇後,將獲得正確的結果,然後再次選擇該代碼時,代碼將正確執行。在鼠標按下功能需要刷新

Private Sub cmdAccounting_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 

If Me.cmdAccounting = 0 Then 

    Me![frmMasterListOfEventsDetailHistory].Form!cost.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!Etichetta35.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!Etichetta37.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!Etichetta43.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!qty.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!tot.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!lineaAccounting1.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!lineaAccounting2.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!FileSaved.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!lblFileSaved.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!Favourite.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!lblFavourite.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!ln01.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!ln02.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!ln03.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!ln04.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!txtInfo.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!ln05.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!ln06.Visible = False 

Else 
    Me![frmMasterListOfEventsDetailHistory].Form!cost.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!Etichetta35.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!Etichetta37.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!Etichetta43.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!qty.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!tot.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!lineaAccounting1.Visible = False 
    Me![frmMasterListOfEventsDetailHistory].Form!lineaAccounting2.Visible = False 

    Me![frmMasterListOfEventsDetailHistory].Form!FileSaved.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!lblFileSaved.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!Favourite.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!lblFavourite.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!ln01.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!ln02.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!ln03.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!ln04.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!txtInfo.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!ln05.Visible = True 
    Me![frmMasterListOfEventsDetailHistory].Form!ln06.Visible = True 

End If 

Me.Form.Refresh 
End Sub 

回答

1

你不必刷新,您必須使用Clik事件,而不是MouseDown

Private Sub cmdAccounting_Click() 
    If Me.cmdAccounting = 0 Then 
    Me![frmMasterListOfEventsDetailHistory].Form!cost.Visible = True 
    Else 
    Me![frmMasterListOfEventsDetailHistory].Form!cost.Visible = False 
    End If 
End Sub 

您的問題: 複選框的狀態MouseDown事件之後發生變化, 所以你結果是錯的, ,你必須用refresh看到好的結果...

+0

太棒了。謝謝 – 2014-11-08 16:51:24