Hi,
I have trouble passing my calculated values to my function. Every time I get the message Type Mismatch:
this is the code I have:
my function definition looks as follows:
I think access means that the values I pass to my functions are not the types my functions expects.
To my simple thinking.... access is wrong but is probably smarter then me
hope someone can help me out
thx
Al
I have trouble passing my calculated values to my function. Every time I get the message Type Mismatch:
this is the code I have:
Dim X As Byte
Dim InschrijfId As String
Dim Cnt4 As Byte
'berekening van STARTnummer lezen van txtPunt velden (start: 1(1-8), 9(9-16), 17(17-24), 25(25-33) etc
'X = stand teller -1 *8 (aantal punten per cursist) +1(startnummer reeks van 8)
'tel tot max. het aantal opgegeven cursisten
'zet variable InschrijfId door de tekst in txtCursist te verkorten totdat alleen
'het inschrijfid overblijft (functie RemoveIt.)
'roep functie saveIt aan met de variabele InschrijfId, om de punten op te slaan met variable punten veld start
For Cnt4 = 1 To Me.txtNrCursisten.Value
InschrijfId = RemoveIt(Me("txtCursist" & CStr(Cnt4)))
X = ((Cnt4 - 1) * 8) + 1
MsgBox "inschrijfid: " & InschrijfId & " En X: " & X
SaveIt "InschrijfId", "X <-- pressing the F8 gives the type mismatch message
Next Cnt4
Dim InschrijfId As String
Dim Cnt4 As Byte
'berekening van STARTnummer lezen van txtPunt velden (start: 1(1-8), 9(9-16), 17(17-24), 25(25-33) etc
'X = stand teller -1 *8 (aantal punten per cursist) +1(startnummer reeks van 8)
'tel tot max. het aantal opgegeven cursisten
'zet variable InschrijfId door de tekst in txtCursist te verkorten totdat alleen
'het inschrijfid overblijft (functie RemoveIt.)
'roep functie saveIt aan met de variabele InschrijfId, om de punten op te slaan met variable punten veld start
For Cnt4 = 1 To Me.txtNrCursisten.Value
InschrijfId = RemoveIt(Me("txtCursist" & CStr(Cnt4)))
X = ((Cnt4 - 1) * 8) + 1
MsgBox "inschrijfid: " & InschrijfId & " En X: " & X
SaveIt "InschrijfId", "X <-- pressing the F8 gives the type mismatch message
Next Cnt4
my function definition looks as follows:
Function SaveIt(InschrijfId As String, X As Byte)
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset 'Instantiate a new recordset
With rst
.Open "TAfdansen", cnn, adOpenDynamic, adLockOptimistic 'Open recordset against table
.AddNew 'Add new record
'.Fields("FieldName") = some Value 'Set values of the various fields
.Fields("InschrijvingsID") = InschrijfId
.Fields("Uitstraling1") = "Me.txtPunt" & X + 0
.Fields("Houding1") = "Me.txtPunt" & X + 1
.Fields("Techniek1") = "Me.txtPunt" & X + 2
.Fields("Maat1") = "Me.txtPunt" & X + 3
.Fields("Uitstraling2") = "Me.txtPunt" & X + 4
.Fields("Houding2") = "Me.txtPunt" & X + 5
.Fields("Techniek2") = "Me.txtPunt" & X + 6
.Fields("Maat2") = "Me.txtPunt" & X + 7
.Update 'Commit the change
End With
rst.Close '--- close the recordset
Set rst = Nothing '--- reclaim the memory the recordset was using
End Function
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset 'Instantiate a new recordset
With rst
.Open "TAfdansen", cnn, adOpenDynamic, adLockOptimistic 'Open recordset against table
.AddNew 'Add new record
'.Fields("FieldName") = some Value 'Set values of the various fields
.Fields("InschrijvingsID") = InschrijfId
.Fields("Uitstraling1") = "Me.txtPunt" & X + 0
.Fields("Houding1") = "Me.txtPunt" & X + 1
.Fields("Techniek1") = "Me.txtPunt" & X + 2
.Fields("Maat1") = "Me.txtPunt" & X + 3
.Fields("Uitstraling2") = "Me.txtPunt" & X + 4
.Fields("Houding2") = "Me.txtPunt" & X + 5
.Fields("Techniek2") = "Me.txtPunt" & X + 6
.Fields("Maat2") = "Me.txtPunt" & X + 7
.Update 'Commit the change
End With
rst.Close '--- close the recordset
Set rst = Nothing '--- reclaim the memory the recordset was using
End Function
I think access means that the values I pass to my functions are not the types my functions expects.
To my simple thinking.... access is wrong but is probably smarter then me

hope someone can help me out
thx
Al