2017-06-30 34 views
-1

好吧,這是我的代碼。我認爲我很接近,但是當frmCondition/Concerns Update窗體打開時,請求strCBOProperty值。我知道這可能是一個語法錯誤,但我不知道它是什麼。Docmd.acbrowsetoform其中子句

Private Sub btnLogin_Click() 
Dim strCBOPassword As String 
Dim strPassword As String 
Dim strCBOProperty As String 

Selectnull 

strCBOProperty = Me.cboProperty.Column(0) 
strCBOPassword = Me.cboProperty.Column(1) 
strPassword = Me.txtPassword 

If strCBOPassword = strPassword Then 
    MsgBox "Login Successful!" 
    DoCmd.BrowseTo acBrowseToForm, "frmCondition/Concerns Update", , "[Forms]![frmCondition/Concerns Update]!cbopropertyname = strCBOProperty" 
Else 
    MsgBox "Invalid Password" 
End If 

末次

私人小組Selectnull() 如果ISNULL(Me.cboProperty)然後 MsgBox 「請選擇一個屬性」,vbOKOnly elseif的ISNULL(Me.txtPassword)然後 MsgBox「請輸入密碼」,vbOKOnly 結束如果 結束小組

+0

查看我的回答。使用'DoCmd.OpenForm'打開一個from,然後構建WhereCondition。 – Andre

回答

0

我說你需要的是這樣的:

DoCmd.OpenForm "frmCondition", WhereCondition:="PropertyName='" & Me.cboProperty.Value & "'" 

如果不是,請告訴我們更多有關cboProperty的內容以及條件表中屬性列的數據類型。

如果你有一個變量的值:

DoCmd.OpenForm "frmCondition", WhereCondition:="PropertyName='" & strCBOProperty & "'" 

的變量必須在外面的字符串。

使用命名參數確保您獲得正確的參數。你在FilterName的位置上有它。

+0

好吧,我這樣做:'如果strCBOPassword = strPassword然後 MsgBox「登錄成功!」 DoCmd.OpenForm「frmCondition/Concerns Update」,「cbopropertyname = strCBOProperty」'但我仍然在爲strCBOProperty提示提示。任何想法爲什麼? –

+0

所以我修正了錯誤,但是當我打開表單時,它沒有過濾。這裏是openform語句:'DoCmd.OpenForm「frmCondition/Concerns Update」,acNormal,,''cbopropertyname =「&strCBOProperty&」'「,acFormPropertySettings,acWindowNormal,''」' –

+0

請仔細看看我的回答,並查看單引號的位置。 @ChrisR – Andre