Page 1 of 3
Using Nu specific functions in forms and objects
Posted: Mon Feb 27, 2023 1:33 am
by tsignadze
Hello, I have a form called change_address, there are two fields : input : TerminalID and display old_address;
I am trying to fetch old address with terminalid from table called address;
I have tried two methods: display sql with :nuFormValue('TerminalID') and also javascript method.
I get not defined errors in console for everything that is nu-specific code.
What should I do?
Re: Using Nu specific functions in forms and objects
Posted: Mon Feb 27, 2023 7:36 am
by kev1n
Hi,
There's no such function nuFormValue() and the syntax is also different.
https://wiki.nubuilder.cloud/index.php? ... tFormValue
PS: It's important to provide as much detail as possible, including the error message you are receiving. Without knowing the specific error(s), we will have to make assumptions about what the issue might be.
Re: Using Nu specific functions in forms and objects
Posted: Mon Feb 27, 2023 11:24 am
by tsignadze
Hello Kevin. This is my first time interacting with NuBuilder, sorry for lack of details.
I will describe my main goals form my application.
I have a table and I want to parse xml and display data from xml, after pressing Add to Merchants button, I want this data to be added in my table. I have parsed xml in a form using javascript and I have javascript variables, now I need to add these variables in my table using SQL Queries.
How can this be achieved?
Re: Using Nu specific functions in forms and objects
Posted: Mon Feb 27, 2023 11:53 am
by kev1n
Set the XML with nuSetFormValue() in the Lookup's After Browse to a form field and use JS (LUJS field) to process it.
Re: Using Nu specific functions in forms and objects
Posted: Tue Feb 28, 2023 11:53 am
by tsignadze
Kevin, thanks for reply!
Are there any in-depth tutorials you are aware of? Can not find anything.
Re: Using Nu specific functions in forms and objects
Posted: Tue Feb 28, 2023 12:01 pm
by kev1n
Do you want to know how to use nuSetFormValue() or something else?
Re: Using Nu specific functions in forms and objects
Posted: Wed Mar 15, 2023 1:27 pm
by tsignadze
kev1n wrote: ↑Tue Feb 28, 2023 12:01 pm
Do you want to know how to use nuSetFormValue() or something else?
Yes, I would like to create custom forms, grab input values from the form fields and put them into sql to update my database.
Please understand, I am coming from MSAccess and can not really get my head around how to setup simple clickable buttons that will run sql queries and CRUD into my database.
Re: Using Nu specific functions in forms and objects
Posted: Wed Mar 15, 2023 1:46 pm
by kev1n
Can you clarify where exactly you are stuck in the process of creating clickable buttons that run SQL queries and perform CRUD operations in your database? Are you having trouble adding the button to your form, adding a click event to the button, or executing the SQL query? Providing more details will help me give you more specific guidance.
Re: Using Nu specific functions in forms and objects
Posted: Mon Mar 20, 2023 9:09 am
by tsignadze
I will describe what I am trying to accomplish coming form MSAccess, I know these two are completely different, but still.
I have a form, where fields on left side is getting filled with uploaded XML, I am parsing and pasting it into those fields. Fields on the right side are hand-filled. Here is a VBA Code which I am running on "Add" button:
To explain: I am checking if serial number is existing in my main table, if it does, then I check if Terminal ID is existing, if it does not I check if serial number is complaint with blank status and if everything checks up, I run a query to add into main table.
You notice that MSAccess can grab values from forms with [] brackets.
How do I replicate this in nubuilder? If I can achieve this I will be able to translate my whole MSAccess project into nubuilder.
form.png
Code: Select all
Option Compare Database
Private Sub AddFiscalMerchant_Click()
Dim count As Integer
count = DCount("SerialNumber", "MainInstances", "[SerialNumber]='" & [Forms]![AddFiscalMerchant]![SerialNumber] & "'")
tidcount = DCount("TerminalID", "MainInstances", "[TerminalID]='" & [Forms]![AddFiscalMerchant]![TerminalID] & "'")
blankstatus = DLookup("Blankornot", "MainInstances", "[SerialNumber]='" & [Forms]![AddFiscalMerchant]![SerialNumber] & "'")
If count = 0 Or blankstatus = "NotBlank" Or tidcount <> 0 Then
MsgBox "Serial Number was NOT FOUND, IS NOT blank or Terminal ID ALREADY EXISTS!", vbCritical
Else
DoCmd.OpenQuery "AddFiscalMerchant", acViewNormal, acAdd
Beep
MsgBox "Merchant has been added successfully!", vbInformation, "Success"
DoCmd.Close acForm, "AddFiscalMerchant"
End If
End Sub
Private Sub CloseWindow_Click()
Dim answer As Integer
answer = MsgBox("You are about to close window, continue?", vbQuestion + vbYesNo)
If answer = vbYes Then
DoCmd.Close acForm, "AddFiscalMerchant", acSaveNo
Else
End If
End Sub
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub SerialNumber_LostFocus()
If Len(SerialNumber.Text) = 9 Then
SerialNumber = SerialNumber.Text
SerialNumber = Left(SerialNumber, 3) & "-" & Mid(SerialNumber, 4, 3) & "-" & Right(SerialNumber, 3)
SerialNumber.Text = SerialNumber
End If
End Sub
Private Sub UploadXMLFile_Click()
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.Title = "Select a XML File"
.Filters.Add "XML File", "*.xml", 1
.AllowMultiSelect = False
If .Show = True Then
xmlFileName = .SelectedItems(1)
' Process XML File
' Dim root As Object
Dim xDoc As Object
Set xDoc = CreateObject("MSXML2.DOMDocument")
xDoc.async = False: xDoc.validateOnParse = False
xDoc.Load (xmlFileName)
Set CommonTemplate = xDoc.DocumentElement
Set TerminalTemplate = CommonTemplate.FirstChild
Set PossessorTemplate = CommonTemplate.LastChild
' Get Root Node
Me.SerialNumber = TerminalTemplate.ChildNodes(1).Text
Me.MerchantName = PossessorTemplate.ChildNodes(0).Text
Me.INN = PossessorTemplate.ChildNodes(2).Text
Me.TerminalID = TerminalTemplate.ChildNodes(4).Text
Me.MerchantID = PossessorTemplate.ChildNodes(1).Text
Me.Address = TerminalTemplate.ChildNodes(2).Text
Me.ReconcilationTime = TerminalTemplate.ChildNodes(8).Text
Me.InstallAppNumber = PossessorTemplate.ChildNodes(3).Text
Me.Profile = TerminalTemplate.ChildNodes(0).Text
End If
End With
End Sub
Re: Using Nu specific functions in forms and objects
Posted: Tue Mar 21, 2023 8:56 am
by kev1n
To upload a file, you can use the File object.
This Tutorial should help you get startet to parse an XML file:
https://www.w3schools.com/xml/default.asp