我的任务是创建Microsoft数据库,以存储客户反馈,并在记录负面反馈时生成可打印的报告。
在我的反馈表单中,用户可以记录反馈细节,我试图开发代码来连接从反馈表(表单的记录源设置为该表)中获取的字段。我的目标是开发一个独特的数字,由反馈表中的以下字段组成:
基本上,我想复制的示例是这样的: Name_Product Name_0712131公司
这些级联字段的输出将存储在名为CF#的反馈表中的另一个字段中。
我应该编写什么样的代码,以便将我想要连接的信息保存到数据库中?
发布于 2013-03-02 17:04:47
添加记录(CurrentDB.Execute({SQL代码})、ADO命令、DAO命令、DoCmd.OpenQuery)有许多不同的方法,但我怀疑您想知道如何创建要添加的表达式:
Dim strCustomerRef As String
'Add the Company Name (assumes the name is in the second column)
strCustomerRef = Me.cboYourComboBox.Column(1)
'Add the Product Name (assumes you have a text box bound to the product)
strCustomerRef = strCustomerRef & "_" & Me.txtTheProductNameTextBox
'Add the date info (assumes you have a text box bound to the date)
strCustomerRef = strCustomerRef & "_" & Format(Me.txtFeedbackDate, "wwmmyy")
'Add the sequence number
strCustomerRef = strCustomerRef & "_" & DCount("CustomerRef", "CF#", "[CustomerRef] Like '" & strCustomerRef & "*'") + 1
'Code to append record here
CurrentDB.Execute "INSERT INTO [CF#] ([CustomerRef], [MoreData]) VALUES ('" & strCustomerRef & "', '" & Me.txtMoreData & "')https://stackoverflow.com/questions/14833565
复制相似问题