Ms access Docmd.acbrowsetoform where子句

Ms access Docmd.acbrowsetoform where子句,ms-access,vba,ms-access-2013,Ms Access,Vba,Ms Access 2013,好的,这是我的代码。我想我很接近了,但是当frmCondition/concerts更新表单打开时,它会询问strCBOProperty值。我知道这可能是一个语法错误,但我不知道它是什么 Private Sub btnLogin_Click() Dim strCBOPassword As String Dim strPassword As String Dim strCBOProperty As String Selectnull strCBOProperty = Me.cboPropert

好的,这是我的代码。我想我很接近了,但是当frmCondition/concerts更新表单打开时,它会询问strCBOProperty值。我知道这可能是一个语法错误,但我不知道它是什么

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() 如果为null(Me.cboProperty),则 MsgBox“请选择一个属性”,仅限vbOKOnly ElseIf为null(Me.txtPassword)则 MsgBox“请输入密码”,仅限VBOK 如果结束
End Sub

我想说你需要这样的东西:

DoCmd.OpenForm "frmCondition", WhereCondition:="PropertyName='" & Me.cboProperty.Value & "'"
如果没有,请告诉我们更多关于
cboProperty
的内容以及条件表中属性列的数据类型

如果变量中有该值:

DoCmd.OpenForm "frmCondition", WhereCondition:="PropertyName='" & strCBOProperty & "'"
变量必须在字符串外部


使用命名参数可确保获得正确的参数。您可以将其放在
过滤器名称
位置。

查看我的答案。使用
DoCmd.OpenForm
打开一个from,并构建where条件。好的,我这样做了:
如果strcboapassword=strPassword,那么MsgBox“Login Successful!”DoCmd.OpenForm“frmCondition/Concerns Update”,“cbopropertyname=strcboaproperty”
但是我仍然得到一个关于strcbboproperty的提示。知道为什么吗?所以我修复了错误,但是当我打开表单时,它没有过滤。以下是openform语句:
DoCmd.openform“frmCondition/Concerns Update”,acNormal,“'cbopropertyname=“&strCBOProperty&'”,acFormPropertySettings,acWindowNormal,“
请仔细查看我的答案,并查看单引号的位置@ChrisR