Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Point and Click Action?

Status
Not open for further replies.

skg

Technical User
Sep 15, 2002
3
US
Hello,

I have a wonderfull DB, which uses a Form as a main window to display summaries of all the records. For obvious reasons changes to the records cannot be made in this Form. Instead the user has to open a change Form, type in the number of the record he wants to change and then make the change.

The above procedure is cumbersome. What I would favor is a "point and click" approach. If the user clicks on the record number in the main Form the change Form, displaying the "clicked at" record should appear.

I have implemented opening the change Form by clicking etc. The only thing missing is how do I pass the number the user clicked on to a macro, so that it can go to the user-selected record(record numbers are unique)?

Regards,

George
 
Use the "Where" Condition of the Macro. This is from the ACCESS 97 Help File for Open Form Action.

Where Condition: A valid SQL WHERE clause (without the word WHERE) or expression that Microsoft Access uses to select records from the form's underlying table or query. If you select a filter with the Filter Name argument, Microsoft Access applies this WHERE clause to the results of the filter.To open a form and restrict its records to those specified by the value of a control on another form, use the following expression:[fieldname] = Forms![formname]![controlname on other form]The fieldname argument is the name of a field in the underlying table or query of the form you want to open. The controlname on other form argument is the name of the control on the other form that contains the value you want records in the first form to match.
Note The maximum length of the Where Condition argument is 256 characters. If you need to enter a more complex SQL WHERE clause longer than this, use the OpenForm method of the DoCmd object in Visual Basic instead. You can enter SQL WHERE clause statements of up to 32,768 characters in Visual Basic.

PaulF
 
Hello PAulF,

thanks for the reply, though my question is not about using a
control from another form :) What I need is a way to know
what dataset record the user has selected by pointing and
clicking. I do not want to have the user enter numbers or
manipulate gadgets, as he could just make things happen
just by point-and-click in the Form listing of the DB dataset
records. To clarify things consider the following:
(ASCII Art follows)

-----------------------------------------------------------------------
+----------------+ +------------------+
| Add Data | | Search Data |
+----------------+ +------------------+
-----------------------------------------------------------------------
NR. Item1 Item2 Item3 Flags
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 First Data Set x y z
2 Second data set r s t
.
.
.
400 Data Set four_hundred u v w

------------------------------------------------------------------------

I would like to open another form displaying record number 327 when the user
hits number 327 and number 4 if the user selects record number 4. I want it to
be point-and-click (like it was on FilemakerPro). The numbers are instances of
a unique integer field in some table, displayed through the form. They are no
control element.

George
 
Point And Click..
You have to click on some type of Control.... However, the "Where Condition" explained above, opens a Form to a specified record, and all records in the RecordSource for that Form will be available. If you only want to have one record available then create a Query for the Edit Form that uses the Control on your 1st Form as the Criteria for the NR (Record Number) Field

Forms!1stFormName.ControlName

Where 1stFormName is replaced by the name of your form, and ControlName is replaced with the name of the Control "bound" to the Field NR.

You have to keep the 1st Form open when you use this method so that the Query can capture the NR Field value.

If you want to close the 1st Form, then you'll have to either store the value of selected record NR Field into either a Table, or a Public Variable. If you store it to a Table then you can "Join" the two tables together on the Fields with the NR data. If you store it to a Public Variable then you can create a Public Function which you can use as the Criteria for the NR Field in your Query. Create the Public Variable and Function in a new Module such as shown below (I assumed the Rec Number Field was Long Interger)

Public lngRecNo as Long

Public Function fRecNo() as Long
fRecNo = NZ(lngRecNo,0)
End Function

Then in the On Click Event for the Control "bound" to the NR Field, set the value

Private Sub txtNR_Click()
lngRecNo = txtNR
End Sub

and in the Query use this for the Criteria for the NR Field

fRecNo()

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top