Topic: Odd Fault

Don't know if it me or a bug, I can't create child records for a database. It works ok from one database but if a delete the relationship and create a new one with another it doesn't work, i have deleted the data and tried, but no luck.
Has anyone else had this problem?

Re: Odd Fault

Hi John,
Never had any issue like that.  Always found MVD to be solid with basic operations like that.
If you attach your project, maybe someone can spot what the problem is.
Derek.

Re: Odd Fault

Hi Derek,

Sorry mate it was me being a prat, I found the problem.
I expect it's me again on this if you could take a look.

select *  from tools
where id_jobs  =  '+mach_tool.edit11.text+'  ;

Trying to display a list from the tools database.
"id_jobs" is a from the tools data and "mach_tool.edit11.text" is from a displayed form.
If i replace mach_tool.edit11.text with a number it works and displays all the tools were id_jobs=2

Many thanks in advance

John

Re: Odd Fault

Hi John,
Are you trying to do this using 'SqlQuery'? (and if so - and just as a matter of interest - any reason why you can't just use 'Search')?
Derek.

Re: Odd Fault

Hi Derek,

Yes i am, trying to select items in the tools database who's id match an entry displayed in a form.

This is the only thing i'm having trouble with.

where id_jobs  =  '+mach_tool.edit11.text+'  ;

This runs ok but not getting the value of '+mach_tool.edit11.text+'
If i replace it with a number it works fine.

John

Re: Odd Fault

Remove the last plus sign quote (+' )

Re: Odd Fault

Hi John,
The syntax you're using ("'+mach_tool.edit11.text+'") is how you would do it in a script.  The syntax is different when you use 'SQLQuery'.
Please have a look at the attached (specifically the 'SQLQuery' code attached to form1.button4 and form1.button5)
In the attachment are 3 different ways (there are others) to do what I believe you're after.
1.  The 'standard' search is using the row you highlight in form1.tablegrid1 to select the relevant tools data (the user only has to click a row rather than type anything in a selection box)
2.  The 'SQLQuery' (only tools table) uses only the tools table (but the weakness of that is that the user is expected to know the value of tools.id_jobs which is perhaps unlikely (and not so user-friendly).
3.  The 'SQL Query' (linking jobs and tools tables) uses both tables to allow the user to enter the job name which they are more likely to know
In all three options, the result is the same (I hope!!) - see the screenshot in the attachment.
Derek.

Post's attachments

Attachment icon john1.zip 451 kb, 217 downloads since 2021-04-02 

Re: Odd Fault

Hi Derek,

That worked a treat, Many many thanks.
If you lived near me in the UK the beers would be on me when the pubs open.
Have a great weekend.

John