Page 1 of 1
Converting from MS Access
Posted: Sat Mar 13, 2021 8:26 pm
by garyvcarter
I have several "Event Procedures" in Microsoft Access that I need to convert.
For example, I have this "OnClick" event on a checkbox on a form that I need to convert. I presume it will go in the Before Save code area. But I have no idea about how to convert this from visual basic. Is there a converter like I see online for converting JavaScript to PHP? Any help would be appreciated!
Code: Select all
Private Sub OnClickEvent_Click()
Dim K As Integer
If Me!Checkmark.Value = True Then
K = K + 1
Else
If K < 1 Then
K = 0
Else
K = K - 1
End If
End If
Me!Count.Value = K
End Sub
Re: Converting from MS Access
Posted: Sat Mar 13, 2021 10:16 pm
by kev1n
Hi,
In nuBuilder, JavaScript is used for client-side scripting and PHP server-side. There might be VBA to JS converters out there (use Google)
Double-click the label of your checkbox to open the Object Properties Dialog. Then in the Tab Custom Code, add an event handler onchange with this code:
Code: Select all
var K = 0; // is K initially 0?
if (this.checked) {
K = K + 1
} else {
if (K < 1) {
K = 0;
} else {
K = K - 1;
}
}
// Replace Count with your nuBuilder object ID.
$('#Count').val(K).change();
Re: Converting from MS Access
Posted: Sat Mar 13, 2021 10:58 pm
by garyvcarter
That is really helpful! I didn't realize (shoulda) that PHP was server-side.
I will have some fiddling to do to make this work but I think I can take it from here.
You are so kind to have helped!
Re: Converting from MS Access
Posted: Sun Mar 14, 2021 6:17 pm
by icoso
Just so you know. All of the AS BS BB and BE code blocks are for PHP only and are executed on the server-side. You can create and call a Javascript routine (nuJavascriptCallback($string1) ) building it in the PHP and these code blocks if you need to. All Javascript to run on the client side should be done in the "Custom Code" of the object (most likely for the onclick that you're trying to do). Each field or label on the form has a Custom Code (click the OBJ button to see all the objects on your form) and so does the form itself (click the Prop button).
Also these links in the Wiki Might be helpful:
Main documentation links:
https://wiki.nubuilder.cloud/ ... umentation
Built-in PHP Functions:
https://wiki.nubuilder.cloud/index.php/PHP
Built-in Javasctript links:
https://wiki.nubuilder.cloud/ ... Javascript
There is not a lot of good examples in the Functions list above, but there are throughout the forums.
Code Snippets repository:
https://github.com/smalos/nuBuilder4-Code-Library (lots of good stuff here.)
Good Luck!
Re: Converting from MS Access
Posted: Sun Mar 14, 2021 9:57 pm
by garyvcarter
Getting clearer as I go! My limited (self and Google taught + one VB course back in the day) experience is all VBA / ASP and thus server-side. I have always been scared of JS stuff.
Got your code to work with a few tweaks. For example k = 1, k+1 got me 11 until I discovered Number(k) + 1 = 2
Those links you included are going on my desktop! (Especially the code library.)
Thanks again. I appreciate it!