a little problem

deepbreath

Registered User.
Local time
Today, 20:43
Joined
Apr 18, 2001
Messages
73
i need adding a click event on my search form, which displays a list of names. if i click on any name it will open the main form of that particular names, and also diables certain buttons on the main form. these buttons should be enabled when i go to main form directly but only disabled when i come to it through search form.
 
The following code will open up your main form to the record you click on the search form, and disable certain buttons.

Private Sub searchresults_Click()
On Error GoTo Err_searchresults_Click

Dim frmMyForm As Form
Dim ctlMyCtls As Control
Set frmMyForm = Forms!MainForm

Dim stDocName As String
Dim rst As Recordset, strCriteria As String
stDocName = "MainForm"
strCriteria = "[criteria]=" & "'" & Me![searchresults] & "'"
DoCmd.OpenForm stDocName

Set rst = Forms!MainForm.RecordsetClone
rst.FindFirst strCriteria
Forms!MainForm.Bookmark = rst.Bookmark
Me!searchresults = ""

For Each ctlMyCtls In frmMyForm.Controls
If ctlMyCtls.Tag = "disable" Then
ctlMyCtls.Visible = True
ctlMyCtls.Enabled = False
ctlMyCtls.Locked = True

Exit_searchresults_Click:
Exit Sub

Err_searchresults_Click:
MsgBox Err.Description
Resume Exit_searchresults_Click
End Sub

searchresults = name of txt box where results are displayed in
Mainform = name of your Mainform
criteria = criteria by which you have done your search/navigate records

For all the buttons you wish to disable, put disable in the tag property

Give it a go, and report any problems you have
HTH

Angelo



[This message has been edited by Angello Pimental (edited 07-12-2001).]
 
my search is based on a query, should i use the name of query in criteria or something else, plz explain
 
Ok, I am assuming that you have a form which displays the search information. And that the form is based on a query.
Then the criteria will be field name by which your query did the search.
e.g. If your user searches for peoples names
then [names] would be the criteria

HTH

Angelo
 

Users who are viewing this thread

Back
Top Bottom