从文本框值Microsoft Access 2007中查看组合框值

时间:2015-04-27 18:24:41

标签: ms-access combobox ms-access-2007

我有一个表格("患者并发症"),用户使用2个级联组合框(" catcombo"" speccombo")将数据输入到表单。组合框从表中提取它们的值("并发症")。该表有一个并发症类别的字段(例如,感染,出血,机械)。第二个字段列出了特定的并发症(例如,如果并发症类别是"出血",具体并发症可能是" GI"或"其他")。组合框的输入被连接并放入表单上的文本字段中(" Complication")。那部分工作正常。

我的表单有几个命令按钮,包括"编辑"并且"保存"命令按钮。因为我不希望用户与"并发症"在表单上的字段中,当"编辑"时,我的字段变得不可见。单击按钮。相反,2个组合框变得可见,并允许用户输入数据。当"保存"如果选择,则发生相反的情况。两个组合框变得不可见,并发症字段变得可见并锁定。

不幸的是,当"编辑"如果选中,则组合框可见,但显示为空白(未选择或显示任何内容)。我试图让框显示给文本字段的输入。例如,如果文本字段显示"出血,其他",我希望catcombo框显示"出血"和speccombo框显示"其他"。我一直无法找到任何效果。如果有人有任何想法,将不胜感激。

相关代码包含在下面。如果我能提供进一步的说明,请告诉我。

Private Sub catcombo_AfterUpdate()
Me.speccombo.Requery
End Sub

Private Sub speccombo_OnCurrent()
Dim strsql As String
strsql = "SELECT [Complications]![Specific Complication] FROM tblComplications" & _
"WHERE [Complication Category]=Forms![Patient Complications]![catcombo].value"
End Sub

Private Sub speccombo_AfterUpdate()
Forms![Patient Complications]![Complication] = Me.catcombo.Value & ", " & Me.speccombo.Value
End Sub

Private Sub save_Click()
    Me.recordcount.Caption = "Record " & Me.CurrentRecord & " of " & Me.Recordset.recordcount
    Me.Patient_Initials.Visible = False
    Date_of_Complication.Locked = True
    Complication.Visible = True
    Complication.Locked = True
    comments.Locked = True
    catcombo.Visible = False
    speccombo.Visible = False
    Me.edit.Visible = True
    Me.edit.SetFocus
    Me.help.Visible = False
    Me.save.Visible = False
    Me.first.Visible = True
    Me.next.Visible = True
    Me.previous.Visible = True
    Me.last.Visible = True
    Me.addnew.Visible = True
    Me.close.Visible = True
    Me.cancel.Visible = False
End Sub

Private Sub edit_Click()
    Me.recordcount.Caption = "Record " & Me.CurrentRecord & " of " & Me.Recordset.recordcount
    Me.Patient_Initials.Visible = False
    Date_of_Complication.Locked = False
    Complication.Visible = False
    comments.Locked = False
    catcombo.Visible = True
    catcombo.Locked = False
    catcombo.Enabled = True
    speccombo.Visible = True
    speccombo.Locked = False
    speccombo.Enabled = True
    Me.cancel.Visible = True
    Me.cancel.SetFocus
    Me.edit.Visible = False
    Me.help.Visible = True
    Me.save.Visible = True
    Me.first.Visible = False
    Me.next.Visible = False
    Me.previous.Visible = False
    Me.last.Visible = False
    Me.addnew.Visible = False
    Me.close.Visible = False
End Sub

0 个答案:

没有答案