Can anyone see where I'm going wrong? I'm trying to click on a button, which goes to a form called 'RelatedMaterials', this works fine. I want this form to have the check boxes on which are ticked according to the Query. This was working fine, exect ot gets to the end and produces an error message. So all I want to do now, is count the records obtained from the Query, something on the lines of:
ContribID is the ID from the original form
myID is the ID of Contributer on the new form
Get the materials associated with the ID selected, and count them.
-ContribID and myID come out at different values, myID is correct though, (I think)
-mySQL just prints out the select statement
I want to just use this number to do a loop so it only goes round x times, and therefore not produce the error message the end. I'm sure I'm making it over complicated...
(I've left in the text I've commented out, as I don't know what's right or wrong!)
Public Sub ShowValue(myID As Long)
Dim dbsComo As Database
Dim rstContMaterials As Recordset
Dim strMessage As String
Dim mySQL As String
'Let ContribID = myID
Debug.Print ContribID
Debug.Print myID
Let mySQL = "SELECT * FROM Query_Contributer/Material_Link WHERE ContribID=" & myID & ";"
'Let mySQL = "SELECT myfield FROM mytable"
Debug.Print mySQL
Set dbsComo = CurrentDb
With dbsComo
'Set rstContMaterials = .OpenRecordset("mySQL")
'Set rstContMaterials = dbsCom
penRecordset(mySQL)
' Show the RecordCount property after populating the Recordset.
rstContMaterials.MoveLast
Debug.Print " RecordCount = " & rstContMaterials.RecordCount
rstContMaterials.Close
End With
End Sub
Please help,I'm totally lost!!!Thank you!!!
Elise
(email: TimFa@cogapp.com)
ContribID is the ID from the original form
myID is the ID of Contributer on the new form
Get the materials associated with the ID selected, and count them.
-ContribID and myID come out at different values, myID is correct though, (I think)
-mySQL just prints out the select statement
I want to just use this number to do a loop so it only goes round x times, and therefore not produce the error message the end. I'm sure I'm making it over complicated...
(I've left in the text I've commented out, as I don't know what's right or wrong!)
Public Sub ShowValue(myID As Long)
Dim dbsComo As Database
Dim rstContMaterials As Recordset
Dim strMessage As String
Dim mySQL As String
'Let ContribID = myID
Debug.Print ContribID
Debug.Print myID
Let mySQL = "SELECT * FROM Query_Contributer/Material_Link WHERE ContribID=" & myID & ";"
'Let mySQL = "SELECT myfield FROM mytable"
Debug.Print mySQL
Set dbsComo = CurrentDb
With dbsComo
'Set rstContMaterials = .OpenRecordset("mySQL")
'Set rstContMaterials = dbsCom

' Show the RecordCount property after populating the Recordset.
rstContMaterials.MoveLast
Debug.Print " RecordCount = " & rstContMaterials.RecordCount
rstContMaterials.Close
End With
End Sub
Please help,I'm totally lost!!!Thank you!!!
Elise
(email: TimFa@cogapp.com)