问题描述
我有一个表,其中包含一个用整数填充的多值字段。 我想读取这些整数的值并进行比较。 代码返回值,但它们不是存储在多值字段中的值。 该代码似乎返回多值字段中关联字段的记录号。 我不明白为什么,在互联网上找不到任何答案。
示例:
假设这个字段包含 20 个值,其中 12 个被选中。
说 1,2,3,5,8,9,13,14,17,18,19,20
被选中。
为了简单起见,假设每个字段都是数字 1
它所做的只是计算所选值的数量,并返回该字段值 1
的当前计数 INSTEAD。
我需要读取字段中的值,无论它们的顺序如何或选择了多少。
Option Compare Database
Public Function MailingListGen(job As String,status As String,check As Integer)
'****************'
'Set up variables'
'****************'
Dim var As Long
Dim val As Long
Dim str As String
Dim str2 As String
Dim excel As Object 'Pointer to Excel Application
Dim book As Object 'Pointer to Excel Workbook
Dim sheet As Object 'Pointer to Excell Sheet
Dim names As DAO.Recordset
Dim classes As DAO.Recordset
Dim child As DAO.Recordset
Dim last_name As DAO.Recordset
Dim comp As DAO.Recordset
'********************************************************'
'Initialize our tables into thier recordsets for analysis'
'********************************************************'
str = "Roster"
Set names = CurrentDb.OpenRecordset(str)
str = "Course List"
Set classes = CurrentDb.OpenRecordset(str)
str = "SELECT Last FROM Roster"
Set last_name = CurrentDb.OpenRecordset(str)
'**************************************************************************'
'Create the new excel file with default parameters and print the cover page'
'**************************************************************************'
Set excel = CreateObject("Excel.Application")
Set book = excel.Workbooks.Add
excel.Visible = True
Set sheet = book.Worksheets("Sheet1")
str = "Mailing List"
sheet.name = str
sheet.Range("B2") = "Missing HLC Mailing List Creator V1"
sheet.Range("B3") = "Written by Levi T Jackson,RN,BSN"
sheet.Range("B4") = "All rights reserved,copyright 2021"
sheet.Range("B5") = "For use only by Emory Healhtcare,and others with permissions"
'**********************************'
'Main Loop,where the magic happens'
'**********************************'
last_name.MoveFirst
names.MoveFirst
str = ""
Do Until last_name.EOF = True
If names!active = status Then
If CheckRole(job) = 1 Then
Set child = names!Completion.Value
If child.EOF = False Then
Do Until child.EOF = True
val = child!Value
str2 = names!First & " " & names!Last
sheet.Range("D11") = str2
str = str & CStr(val) & ","
sheet.Range("D10") = str
child.MoveNext
Loop
End If
child.Close
Set child = nothing
End If
End If
Exit Do
names.MoveNext
last_name.MoveNext
Loop
sheet.Range("B9") = "Mailing list for staff missing HLC with ID " & CStr(check)
'Clean up recordsets
last_name.Close
names.Close
Set names = nothing
classes.Close
Set classes = nothing
End Function
Private Function CheckRole(name As String) As Integer
CheckRole = 1
End Function
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)