|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Reference a single instance of a control on continuous form
I want to reference a particular instance of a control which is on a form formatted as a continuous form. The only way I can see to do it is to cycle through all the controls on the form until I find the Index for the one I want. This seems to be combersome (about 100 controls) and it would have to be repeated frequently.
|
|
#2
|
||||
|
||||
|
Private Sub FindRecordinContinuousForm(SearchField, SearchValue As String)
'replace above line with searchvalue as long if datatype is long 'and so on Dim rst As Recordset, strCriteria As String 'if string use next line strCriteria = "[" & SearchField & "] Like '" & SearchValue & "'" 'else use the next line ' strCriteria = "[" & SearchField & "] Like " & SearchValue Set rst = Me.RecordsetClone rst.FindFirst strCriteria If rst.NoMatch Then MsgBox "No entry found" Else Me.Bookmark = rst.Bookmark End If End Sub call the above function like if the field you want to search is itemid, value you search is 'ironbar' and if the datatype is string call FindRecordinContinuousForm("ItemID","ironbar") you can place the above line on any click event of a button or as you wish.
__________________
V.Subramanian |
|
#3
|
|||
|
|||
|
you can also try this
Dim rs As DAO.Recordset Dim ival As Integer ' 'If we are not adding a new record then we want to see if the user has 'selected a particular item on the main form. If so then go to that record. ' If Not (Me.NewRecord) Then Set rs = Me.RecordsetClone If rs.AbsolutePosition = -1 Then Else If Not IsNull(Forms!mnuMain!lstItems) Then rs.FindNext ("ItemNbr = " & Forms!mnuMain!lstItems.Column(1)) ival = rs.AbsolutePosition DoCmd.GoToRecord , , acGoTo, ival + 1 End If End If End If rs.Close you can set a recordsetclone for the underlying recordset for the form. Then do a findnext where the field (ItemNbr) is equal to a specific value (Forms!mnuMain!lstItems.Column(1))) This returns the absolute position of the record in the recordset and by adding 1 you get the actual position to goto. Once the record is set you can address the underlying data in the table by referencing the field names in the form. You can also get data from any record without the gotorecord because you have that info available once you have done the recordsetclone. When you do the findnext the information for that record is available just by referencing the field names in the underlying table or query for the form. |
|
#4
|
|||
|
|||
|
Thanks for the replies.
I will go through the samples for some ideas but you might have misunderstood the question. The samples seem to relate to finding records. What I need to reference are the controls so that I can alter their formatting. Conditional formating can get me part of the way but it is not available in Access97 anyway. |
|
#5
|
|||
|
|||
|
I see. You can't do that. In a continuous form there is only one instance of the control that is accessible and if you change it you change all of the copies.
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Reference a single instance of a control on continuous form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|