ChristinaFC
IS-IT--Management
I have a piece of code (a function) that is used in many of the forms in my Access 2007 db. The code contains me. -references, and as I have understood it, me. does not work in modules. Is there some other reference that can be used instead?
Example of the code:
'Makes company name and PersonID3 load to combobox when three letters are typed into the box
Sub ReloadcboPersonID3(strTextICbo As String)
Const conPerson2Min = 3
If Len(strTextICbo) > conPerson2Min Then GoTo LastLine
Dim strPersonNamnStub As String
Dim strNewStub As String ' First chars of texten i cbo
'You can use the Nz function to return zero, a zero-length string (" "), or another specified value when a Variant is Null. expression.Nz(Value, ValueIfNull)
strNewStub = Nz(Left(strTextICbo, conPerson2Min), "")
' If first n chars are the same as previously, do nothing.
If strNewStub <> strPersonNamnStub Then
If Len(strNewStub) < conPerson2Min Then
'Remove the RowSource
Me.cboPersonID3.RowSource = ""
strPersonNamnStub = ""
Else
'New RowSource
Me.cboPersonID3.RowSource = "SELECT fldPersonExklFtg, PersonPID FROM qryPersonLista WHERE (fldPersonExklFtg Like """ & strNewStub & "*"")"
strPersonNamnStub = strNewStub
Me.cboPersonID3.Dropdown
End If
End If
LastLine:
End Sub
Example of the code:
'Makes company name and PersonID3 load to combobox when three letters are typed into the box
Sub ReloadcboPersonID3(strTextICbo As String)
Const conPerson2Min = 3
If Len(strTextICbo) > conPerson2Min Then GoTo LastLine
Dim strPersonNamnStub As String
Dim strNewStub As String ' First chars of texten i cbo
'You can use the Nz function to return zero, a zero-length string (" "), or another specified value when a Variant is Null. expression.Nz(Value, ValueIfNull)
strNewStub = Nz(Left(strTextICbo, conPerson2Min), "")
' If first n chars are the same as previously, do nothing.
If strNewStub <> strPersonNamnStub Then
If Len(strNewStub) < conPerson2Min Then
'Remove the RowSource
Me.cboPersonID3.RowSource = ""
strPersonNamnStub = ""
Else
'New RowSource
Me.cboPersonID3.RowSource = "SELECT fldPersonExklFtg, PersonPID FROM qryPersonLista WHERE (fldPersonExklFtg Like """ & strNewStub & "*"")"
strPersonNamnStub = strNewStub
Me.cboPersonID3.Dropdown
End If
End If
LastLine:
End Sub