I am back at it after 4 years of no App Studio work. My SQL is quite weak. So here is the deal.
I have a table that I am loading with Form1 and displaying the results in a grid. This all works quite well.
On Form2 called from Form1 I am trying to retrieve one record from the table using the Select-where statement. A number is entered into txtBoat field and the “Find Boat” button is clicked to execute the select below. Nothing is returned. Actually there is no proof the Select is actually executed as the success function is never executed. Here is the code:
MsgBox("Select * from tblWeighin where Boat1= "& txtBoat.value &";")
sqlList=["Select * from tblWeighin where Boat1= "& txtBoat.value &";",LoadForm,BadGetBoat]
MsgBox("start of load form")
DBRecords = results
I use the Msgbox to check the form of the select statement and also to indicate if LoadForm was entered.
Any thoughts on where I am going wrong?
Thanks in advance!
Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly. (We fixed it for you this time)
Using a MsgBox in an onclick event can result in unexpected behaviour, as the events don’t happen as you might expect. Use a console.log() statement instead, and see what is in the console at runtime.
Thank you for the feedback.
Entering a known value in the txtBoat field has the success function “LoadForm” execute and a formatted console log message for DBRecords.rows.length returns 0. I also put in an invalid value for the lookup and the success function still executes. Thoughts??
A lookup with an „invalid value“ still executes successfully - it just returns no record, but that‘s not an error, 0 records is a valid result.
What‘s the contents of the field „Boat1“ - is that numeric, or a text string? If it‘s a string, I think you need some additional double quotes around „txtBoat.value“ in the select statement filling sqlList . Let me do a little test later and come back.
I think the SQL statements should look like this (note the double double quotes added)
In function btnFindBoat_onclick():
MsgBox(“Select * from tblWeighin where Boat1= “””& txtBoat.value &""";")
(not important as this is only showing the statement for information)
sqlList=[“Select * from tblWeighin where Boat1= “””& txtBoat.value &""";",LoadForm,BadGetBoat]
here it is important!
The SQL statement generated then looks like this, assuming I have entered “BoatName1” into the text area txtBoat:
Select * from tblWeighin where Boat1= “BoatName1”;
so it works with any boat name. Only if your boat names are plain numbers you can leave out the double quotes I added.
Hot dang, Thomas… works slick. thank you !