Can double-click replace a button?

A simple question. With a control table where you can list movie names in rows, could you just double click the record marker rather than selecting a row and clicking a button to jump to that record in another form?

Hello,

Need macro. See my answer with sample here → Base Macro - Click on Table Row to Open Record

Uses single click. Adjust code if double wanted. Many posts reffering to detecting double click already posted

Ratslinger,
.
Good, I downloaded your sample, but it doesn’t quite work as I wanted, because it’s the whole control table reacting to mouse click. There is no longer any possibility to make a selection in the list box of the table.
.
I was looking for the following way:
.

1 - Select a row
2 - Double-click the record marker
3 - Open the form and access the selected record.

.
For the moment, a button remains the best solution.
.
All the same, thank you!

@Renel
.
Guess you did not apply the double click method. With that i works as you asked for.
.
Quick search on double click produces first entry of → Can Base handle a mouse double-click? .
.
Apply that to the sample

Change opening line from:

Sub	GetID()

to:

 Sub	GetID(oEvt)

and add this after the Dim statements:

If oEvt.ClickCount <> 2 then
    Exit sub
End if

That’s it.

1 Like

Thank you Ratslinger and PhilipK!
.
The procedure works fine after making the suggested changes for the double-click and after adding the oSub variable from PhilipK’s procedure. My control table being in a sub-form, adding this single line of code made it all work. I simply eliminated the variables and lines of code that were not useful to me.
.
Really cool guys, thanks!

Please be careful with your descriptions of setup. This was never mentioned anywhere for this question, and we cannot see what you are actually looking at.
.
Often this is why samples are asked for.

.
You are right. Besides, I should have done a search first to see if there were already solutions to this.
.
All the same, I’m happy to be able to add this functionality to my DB.
.
Thanks!

This is the code I used. Double-clicking (anywhere) on a row in the table-grid reads the key field (here “Vessno”), opens a second form (here “EntryForm”) and filters the content to match that key. (Filtering is far quicker than searching in LibreOffice, though it does not enable you to scroll through the table in the second form.)

SUB VessNo_DoubleClick (oEvent)
REM  Open EntryForm filtered for selected vessel no.
REM  Attached to Mouse-Button-Pressed event for table, not individual field
	Dim oForm, oSub, oTable, oField, EntryForm as Object
	Dim VessFilter as String
	
	If oEvent.clickCount = 2 then
		oForm = ThisComponent.Drawpage.forms.getByName("MainForm")
		oSub = oForm."Refs_on_pubs"
		oTable = oSub."RefsTable"
		oField = oTable."VessNo"  
REM  This drills down to key field of active record
		VessFilter = oField.value
REM  Now open second form
		EntryForm = ThisDatabaseDocument.FormDocuments.getByName("F-EntryForm")
		EntryForm.open()
		oForm = EntryForm.getComponent().getDrawPage().getForms().getByName("MainForm")
		Wait 100  
REM  Apply filter to key field
		oForm.filter = ("[T-Stamps].[Pot No.] = " & VessFilter)
		oForm.reload()
	endif
END SUB
1 Like