Hi,
I am trying to write a routine that I can call to update a series of index's as required.
I am trying to pass to the routine a variable containing the control name on the form to be updated, and I am having trouble putting the value I want into the form variable rather then just assigning it to a variable name.
The code I am using is below, and the result I want is that the updated index number is put into the control passed in via the variable "controlname" an example of this is me.enquiryID
Private Sub IndexUpdate(IndexType As String, ControlName As String)
Dim strsql As String
Dim con As Object
Dim rstIndexNo As New Recordset
Set con = Application.Application.CurrentProject.Connection
strsql = "select IndexNo from tblIndexes where index = '" & IndexType & "'"
rstIndexN
pen strsql, con, adOpenKeyset, adLockOptimistic
rstIndexNo!IndexNo = ((rstIndexNo!IndexNo) + 1)
ControlName = rstIndexNo!IndexNo
rstIndexNo.Update
End Sub
I realise what I have above just changes the valus of the varialbe controlname but I'm not sure how to get what I want.
Thanks for your help.
Sue
I am trying to write a routine that I can call to update a series of index's as required.
I am trying to pass to the routine a variable containing the control name on the form to be updated, and I am having trouble putting the value I want into the form variable rather then just assigning it to a variable name.
The code I am using is below, and the result I want is that the updated index number is put into the control passed in via the variable "controlname" an example of this is me.enquiryID
Private Sub IndexUpdate(IndexType As String, ControlName As String)
Dim strsql As String
Dim con As Object
Dim rstIndexNo As New Recordset
Set con = Application.Application.CurrentProject.Connection
strsql = "select IndexNo from tblIndexes where index = '" & IndexType & "'"
rstIndexN
rstIndexNo!IndexNo = ((rstIndexNo!IndexNo) + 1)
ControlName = rstIndexNo!IndexNo
rstIndexNo.Update
End Sub
I realise what I have above just changes the valus of the varialbe controlname but I'm not sure how to get what I want.
Thanks for your help.
Sue