Java script to VBA question

egpicc

New Member
Joined
Feb 27, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello everybody! First, a brief background about my issue to make it possible to understand my question. I have been an SPSS Data Entry software user since 1995. It ran perfectly under Windows XP and Windows 7. A great program that would allow you to use JAVA scripts to skipping fields depending on the value of an entered data. Inasmuch the program does not run under Windows 10 or Windows 11, I decided to create surveys data entry using MS Access or Excel, but to be honest, I can´t find the equivalent command to accomplish the following JAVA script:

function Form1_Question2_SkipFill(thisRespObj, thisVar) // Generated by wizard
{
if ((Vars.P11.Value == 99))
{
Forms.Form1.Question4.SetFocus()
}
else
{
// by default focus will go to the next question
}
}

Which means If the value of the variable P11=99 skip to field named Question4 else go to next field by default, in the same form and record of course.

Can some please help me? Please take into account that I am user of different programs whose programming skills are no so developed, but willing to keep on learning.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi!

If the value is coming directly from a user input (textbox, etc), you might look at the .AfterUpdate event for controls to trigger the code. Otherwise, it can be as simple as
VBA Code:
    If P11 = 99 Then
        SkipToObjectName.SetFocus
    Else
        NextQuestionObjectName.SetFocus
    End If
 
Upvote 0
Solution
Hi!

If the value is coming directly from a user input (textbox, etc), you might look at the .AfterUpdate event for controls to trigger the code. Otherwise, it can be as simple as
VBA Code:
    If P11 = 99 Then
        SkipToObjectName.SetFocus
    Else
        NextQuestionObjectName.SetFocus
    End If
Thank you very much. I will try it and inform you.
 
Upvote 0
Thank you very much. I will try it and inform you.
Hi!

If the value is coming directly from a user input (textbox, etc), you might look at the .AfterUpdate event for controls to trigger the code. Otherwise, it can be as simple as
VBA Code:
    If P11 = 99 Then
        SkipToObjectName.SetFocus
    Else
        NextQuestionObjectName.SetFocus
    End If

Thanks a lot, severynm! At the end what I did was to use the property .AfterUpdate in Access and created a macro in order to skip every time the value 99 is entered. Now, I can design any database regarding written questionnaires in Access and handle this type of code. In market research we use this value of 99 as the standard code for “Didn’t answer/Didn’t know” (DA/DK). This way we skip the rest of options of a multi response type of question. But to be honest, I miss the SPSS Data Entry program.☹️ Anyhow, it is never to late to keep on learning! ?
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top