![]() ![]() Imagine a Company has Departments which have People. Lookdown.SetRowNumberFromID_sub(oForm.getByName("Grid").getRowSet, oResults, iSelectedID) 'Get a row# from the selected ID ' Lookdown.SetRowNumberFromID_sub(oForm, oResults, iSelectedID) 'Get a row# from the selected ID 'The grid to locate the record in must be named "Grid" OResults = oConnection.createStatement().executeQuery(sSQL) SSQL = oForm.ActiveCommand & iif(oForm.Order="",""," ORDER BY " & oForm.Order) Their order needs to be the same as for the underlying table!!! 'Skip if not found (because string is not yet a valid value from the list)ĭim iSelectedIDĚs Integer: iSelectedID = oResults.getInt(2) 'Extract ID for the selected item (2 = column # 2) ' On Error Goto 0 'Deactivate error handling ' oResults.First() 'If error here then can't find the lookup string (empty dataset?), so something is wrong. ' oSQL.ResultSetType = .ResultSetType.SCROLL_INSENSITIVE 'For HSQLDB 1.8 (not for MySQL)ĭim oResultsĚs Object :tString(1,Text$): oResults = oSQL.executeQuery() 'Execute SQL statement with parameter & get results ' Dim sSQL As String :sSQL = "SELECT *" & sFROM & " WHERE ""Choice"" = ?" & sOrderBy 'For HSQLDB 1.8ĭim oSQL As Object :oSQL = oConnection.prepareStatement(sSQL) 'Create SQL prepared statement the thing that will carry out the SQL-command 'Ēnd field: Must be the record's unique ID (for the getInt(2) below)ĭim sSQL As String :sSQL = "SELECT *" & sFROM & " WHERE `Choice` = ?" 'For MySQL 'đst field: must be named "Choice" (for the WHERE below), and Note, the recordset in the combo box is like this: ' Dim sFROM As String :sFROM = " FROM (" & sSelect & ") AS Foo " 'HSQLDB 1.8 'Get SQL that created the combo box, and make it ready to nest into other SQL statementsĭim sFROM As String :sFROM = " FROM (" & oForm.getByName().ListSource & ") AS Foo" 'MySQL ' Dim sOrderByĚs String :sOrderBy = Right(sLstSrc, Len(sLstSrc)-iOrderBy) 'HSQLDB 1.8 'HSQLDB ' Dim sSelect As String :sSelect = Left(sLstSrc, iOrderBy) 'HSQLDB 1.8 ' Dim iOrderByĚs Integer:iOrderBy = InStr(sLstSrc, " ORDER BY")-1 'HSQLDB 1.8 ![]() ' Dim sLstSrc As String :SLstSrc = oForm.getByName().ListSource 'HSQLDB 1.8 Private Sub FindRecord_(oEvent As Object, Text$ As String)ĭim oForm As Object :oForm = 'Our form - the form that holds this combo box (and has connects to the database!)ĭim oConnectionĚs Object :oConnection = oForm.activeConnection() 'Connect to our form's database This all may or not help you, but if you dig in I think you’ll find how to do it.įirst, I have this sub I use to move to the last record: Private Sub DrawPage_(oForm As Object)ĭim oDocĚs Object : oDoc = ThisComponentĪlso I have a sub to move the record pointer to a specific record: ' - primitive used above (2 places) Version: MariaDB / MySQL I did have to work around the fact that LO doesn’t have the function that Access has to do this. I don’t have time to spoon feed this to you, but here is my working code that does this a couple of ways for one table I use. What is the command for “Find Record” in Macros? Is there a list of commands? The documentation written by Andrew Pitonyak appears to be useful, but requires a lot of time to find relevant data and then interpret it. Eventually I’d set it up to return to the last selected record in M圜ollection. At this stage, all I want to do is to return to the last selected Country whenever I open a form. My Philately Database is normalised and consists of a Country Table linked to Stamps linked to M圜ollection. ![]() All I want to do is Open a Form and go to a specific record, rather than Opening the form and then having to scroll through the records to the specific one. There does not appear to be a simple answer to this.
0 Comments
Leave a Reply. |