微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Recordset.absoluteposition 的 DLookup 函数?

如何解决Recordset.absoluteposition 的 DLookup 函数?

如果有人可以帮助我,我将不胜感激。我已经完成了 95% 的项目,但我被困在了最后一个任务中。

基本上,我有一个函数可以搜索 Access 数据库中的所有表并在列表框中返回找到的值。一切正常,除非我在一个表中有相同的字符串,然后我的 dlookup 返回它获得的第一个值。但是在某些表中,该值仅记录一次,并且该函数当然可以工作。我试图获得基于 Recordset.absoluteposition 的 DLookup 并且我现在失败了好几天没有任何解决方案。我在这个项目中搜索了自己的方式,但我不是专家。有人可以帮我吗?:/这是我的代码

Public Function fSearchForString(strSearchString) As Boolean
On Error GoTo Err_fSearchForString
 
Dim tdfa As dao.TableDef
Dim MyDBs As dao.Database
Dim MyRS As Recordset
Dim intNumOfFields As Integer
Dim intCounter As Integer
 
Set MyDBs = CurrentDb
 
DoCmd.Hourglass True
  
For Each tdfa In CurrentDb.TableDefs
  If Not tdfa.Name Like "MSys*" Or Not tdfa.Name Like "MSys*" Then    'ignore System Tables
    Set MyRS = MyDBs.OpenRecordset(tdfa.Name,dbOpenDynaset)
      intNumOfFields = MyRS.Fields.Count
        For intCounter = 0 To intNumOfFields - 1
          do while Not MyRS.EOF
            If InStr(MyRS.Fields(intCounter).Value,strSearchString) > 0 Then

Dim stringergebnis As Variant
stringergebnis = MyRS.Fields(intCounter).Value
Dim rackpos As Variant
rackpos = tdfa.Name
Dim rackposition As Variant
rackposition = DLookup("Rack_Position",tdfa.Name,"[Auftragsnummer]= '" & stringergebnis & "'")
Dim rackmaterial As Variant
rackmaterial = DLookup("Material","[Auftragsnummer]= '" & stringergebnis & "'")
Dim rackvon As Variant
rackvon = DLookup("absort_Zeit","[Auftragsnummer]= '" & stringergebnis & "'")


Forms!Probe_suchen.Liste103.AddItem Item:="" & "'" & stringergebnis & "'" & ";" & "'" & rackpos & "'" & ";" & "'" & rackposition & "'" & ";" & "'" & rackmaterial & "'" & ";" & "'" & rackvon & "'" & ""

 
            End If
            MyRS.MoveNext
          Loop
          MyRS.MoveFirst
        Next
  End If
Next
 
DoCmd.Hourglass False
 
MyRS.Close
Set MyRS = nothing
 
fSearchForString = True
 
Exit_fSearchForString:
  Exit Function
 
Err_fSearchForString:
  fSearchForString = False
  MsgBox Err.Description,vbExclamation,"Error in fSearchForString()"
  DoCmd.Hourglass False
  If Not MyRS Is nothing Then
    MyRS.Close
    Set MyRS = nothing
  End If
    Resume Exit_fSearchForString
End Function

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。