Futures_Bright
Registered User.
- Local time
- Today, 00:12
- Joined
- Feb 4, 2013
- Messages
- 69
Hi all,
Firstly, I'm aware it's bad practice to use multi-valued comboboxes, but for the fields I use them it is a much nicer/cleaner input for the user to use.
The problem comes when copying to a similar record (for updated records I create a copy of the previous except for the change - this is because a record of the review of each record needs to be maintained).
I have a function in my code which, to be honest I forgot I had put in and don't know where I got it from (and have renamed variables to suit my application) - see below:
I definitely didn't write this myself because working with recordsets is something I'm not confident with! I'm now trying to call this function and can't for the life of me work out what intIndex is for and what I should input into the function? I don't know why this function needs to check if this intIndex is bigger than the record count for the recordset?
Any help/guidance (even alternate code) would be appreciated!
Kind regards,
Michael
Firstly, I'm aware it's bad practice to use multi-valued comboboxes, but for the fields I use them it is a much nicer/cleaner input for the user to use.
The problem comes when copying to a similar record (for updated records I create a copy of the previous except for the change - this is because a record of the review of each record needs to be maintained).
I have a function in my code which, to be honest I forgot I had put in and don't know where I got it from (and have renamed variables to suit my application) - see below:
Code:
Public Function ReturnApplicabilityByIndex(ctl As Control, intIndex As Integer) As Variant
Dim rstAppVal As DAO.Recordset 'array values from Applicability
Dim lngCount As Long 'for copying Applicability
Dim intRecord As Integer 'for copying Applicability
Set rstAppVal = ctl.Parent.Recordset(ctl.ControlSource).Value
rstAppVal.MoveLast
lngCount = rstAppVal.RecordCount
If intIndex > lngCount - 1 Then
MsgBox "The requested index exceeds the number of selected values."
GoTo exitRoutine
End If
rstAppVal.MoveFirst
Do Until rstAppVal.EOF
If intRecord = intIndex Then
ReturnApplicabilityByIndex = rstAppVal(0).Value
Exit Do
End If
intRecord = intRecord + 1
rstAppVal.MoveNext
Loop
exitRoutine:
rstAppVal.Close
Set rstAppVal = Nothing
Exit Function
End Function
I definitely didn't write this myself because working with recordsets is something I'm not confident with! I'm now trying to call this function and can't for the life of me work out what intIndex is for and what I should input into the function? I don't know why this function needs to check if this intIndex is bigger than the record count for the recordset?
Any help/guidance (even alternate code) would be appreciated!
Kind regards,
Michael