Which event on datasheet

groengoen

Registered User.
Local time
Today, 22:29
Joined
Oct 22, 2005
Messages
141
I have a subform in datasheet view. I want to select a line and use one of the fields in this record to open another form with this field key in the "WHERE" of the SQL selection. I have the following code:

Dim strWhere As String
strWhere = "[FormNo] = " & Me.FormNo & " "
DoCmd.OpenForm "LIFE1209", acNormal, , strWhere

This works to open the form when I put it on one of the controls on the datasheet, but I want it to operate whenever I select a line on the datasheet. Which event will I put the above code into? I have tried on the Selection event in the Detail section to no avail,

Thanks in advance,

Groengoen
 
I believe that you want the On_Current event of the subform.
 
Thanks but that doesn't seem to work either!

Groengoen
 
I get the following when I put the code as above into the OnCurrent event:

Run-Time error '3075'
Syntax error (missing operator) in query expression '[FormNo] ='

Although I have just copied and pasted the same query expression from the control to this event. I wonder if you would know what causes this

Thanks

Groengoen
 
Expressions on controls have different syntax than in code.
 
I assume you mean when you place the cursor in a field on a form.

If that is so, put your code behind the on click or on exit event

George
 
The OnCurrent event got working but what it means is that whenever I click on a record in the main form it automatically goes to the other form (because a record becomes current in the subform). What I wanted to do was select a line in the subform datasheet which would trigger the opening of the other form. I can do it on an individual field, but what I wanted was that as soon as the line was selected the event would be triggered.

Thanks for the advice so far

Groengoen
 

Users who are viewing this thread

Back
Top Bottom