Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Converting from MS Access

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
garyvcarter
Posts: 3
Joined: Thu Mar 04, 2021 5:07 pm

Converting from MS Access

Unread post 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
kev1n
nuBuilder Team
Posts: 4302
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Converting from MS Access

Unread post 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();
You do not have the required permissions to view the files attached to this post.
garyvcarter
Posts: 3
Joined: Thu Mar 04, 2021 5:07 pm

Re: Converting from MS Access

Unread post 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!
icoso
Posts: 181
Joined: Sun Feb 07, 2021 11:09 pm
Been thanked: 1 time

Re: Converting from MS Access

Unread post 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!
garyvcarter
Posts: 3
Joined: Thu Mar 04, 2021 5:07 pm

Re: Converting from MS Access

Unread post 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!
Post Reply