-
December 6th, 2011, 08:24 PM
#1
ByRef Argument Type Mismatch help
I have inherited a program that needs work. I have been staring at this for days, and am missing the answer. I am getting a ByRef Argument Type Mismatch when I compile:
Public Sub LoadShifts()
Dim tb As Recordset
Dim cString As String
If lstRank.Text = "<ALL>" Then
Set tb = DB.OpenRecordset("Select Shift,Rank,ShiftOneLetter,ID From Shifts" & _
" Where IsNumeric(Shift) Order By Shift")
Else
Set tb = DB.OpenRecordset("Select Shift,Rank,ShiftOneLetter,ID From Shifts " & _
"Where IsNumeric(Shift) And " & _
"Rank Like '*" & lstRank.ItemData(lstRank.ListIndex) & _
"*' Order By Shift")
End If
grdShifts.SelectionMode = flexSelectionByRow
grdShifts.AllowBigSelection = True
grdShifts.FillStyle = flexFillSingle
grdShifts.ColWidth(0) = 650
grdShifts.ColWidth(1) = 975
grdShifts.ColWidth(2) = 500
grdShifts.ColAlignment(0) = flexAlignCenterCenter
grdShifts.ColAlignment(1) = flexAlignLeftCenter
grdShifts.ColAlignment(2) = flexAlignCenterCenter
grdShifts.TextMatrix(0, 0) = "Shift"
grdShifts.TextMatrix(0, 1) = "Rank(s)"
grdShifts.TextMatrix(0, 2) = "ID"
PopulateFlexGrid grdShifts, tb
tb.Close
End Sub
What am I missing? Thank you for any help you can provide.
-
December 6th, 2011, 11:12 PM
#2
Re: ByRef Argument Type Mismatch help
What am I missing? Thank you for any help you can provide.
1. Need CODE TAGS (Like QUOTE tags)
2. More Code needs to be shown (see #2)
3. Mark the line with the error in RED or BOLD
Thanks!
-
December 7th, 2011, 06:50 AM
#3
Re: ByRef Argument Type Mismatch help
Public Sub LoadShifts()
Dim tb As Recordset
Dim cString As String
If lstRank.Text = "<ALL>" Then
Set tb = DB.OpenRecordset("Select Shift,Rank,ShiftOneLetter,ID From Shifts" & _
" Where IsNumeric(Shift) Order By Shift")
Else
Set tb = DB.OpenRecordset("Select Shift,Rank,ShiftOneLetter,ID From Shifts " & _
"Where IsNumeric(Shift) And " & _
"Rank Like '*" & lstRank.ItemData(lstRank.ListIndex) & _
"*' Order By Shift")
End If
grdShifts.SelectionMode = flexSelectionByRow
grdShifts.AllowBigSelection = True
grdShifts.FillStyle = flexFillSingle
grdShifts.ColWidth(0) = 650
grdShifts.ColWidth(1) = 975
grdShifts.ColWidth(2) = 500
grdShifts.ColAlignment(0) = flexAlignCenterCenter
grdShifts.ColAlignment(1) = flexAlignLeftCenter
grdShifts.ColAlignment(2) = flexAlignCenterCenter
grdShifts.TextMatrix(0, 0) = "Shift"
grdShifts.TextMatrix(0, 1) = "Rank(s)"
grdShifts.TextMatrix(0, 2) = "ID"
PopulateFlexGrid grdShifts , tb
tb.Close
End Sub
------------------
I copied and pasted exactly what is there...this is the only part that appears to have an error. I hope this helps.
-
December 7th, 2011, 09:14 AM
#4
Re: ByRef Argument Type Mismatch help
The cause of the problem seems to be the routine PopulateFlexGrid.
You should check the definition which is like
Code:
Private Sub PopulateFlexGrid(...)
The error message gives a hint that one of the arguments is possibly not properly declared.
Please find this procedure and show it to us.
-
December 7th, 2011, 09:36 AM
#5
Re: ByRef Argument Type Mismatch help
Originally Posted by WoF
The cause of the problem seems to be the routine PopulateFlexGrid.
You should check the definition which is like
Code:
Private Sub PopulateFlexGrid(...)
The error message gives a hint that one of the arguments is possibly not properly declared.
Please find this procedure and show it to us.
Public Function PopulateFlexGrid(FlexGrid As Object, _
rs As Object) As Boolean
' On Error GoTo ErrorHandler
If Not TypeOf FlexGrid Is MSFlexGrid Then Exit Function
Dim i As Integer
Dim j As Integer
FlexGrid.FixedRows = 1
FlexGrid.FixedCols = 0
On Error Resume Next
rs.MoveLast
rs.MoveFirst
On Error GoTo ErrorHandler
FlexGrid.TextMatrix(1, 0) = ""
FlexGrid.TextMatrix(1, 1) = ""
If Not rs.EOF Then
FlexGrid.rows = rs.RecordCount + 1
FlexGrid.cols = rs.Fields.Count
i = 1
Do While Not rs.EOF
For j = 0 To rs.Fields.Count - 1
If Not IsNull(rs.Fields(j).value) Then
FlexGrid.TextMatrix(i, j) = rs.Fields(j).value
End If
Next
i = i + 1
rs.MoveNext
Loop
Else
FlexGrid.rows = 2
End If
PopulateFlexGrid = True
ErrorHandler:
Exit Function
End Function
-
December 7th, 2011, 11:38 AM
#6
Re: ByRef Argument Type Mismatch help
Hm, that's strange. Could you please make a screenshot of the error message popup?
You sure the line
PopulateFlexGrid grdShifts , tb
pops up the error?
A declaration like Public Function PopulateFlexGrid(FlexGrid As Object, rs As Object) As Boolean
should not provoke an error, because Object can be any object reference.
And please start using code tags next time you post code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|