How can I set the default value in an Access form using a command button and VBA? - ms-access-2010

I am working on a form that I need to change the default value for a control during run time without having to go into design mode. I need to use a command button and either VBA or a Macro. What will happen is when the user needs to change a location they are working with for an audit, they click on the button and get a prompt to change the location by scanning a barcode and then refresh the form so that it will display the new location.
I know it can be done, I did it with another database about 8 years ago, I just can't remember how I did it.
This is what I am trying to do. I am trying to keep it as simple as possible, since if something goes wrong I may not be the one that needs to fix it.
Me.Form.frmEntry.txtLocation.DefaultValue = InputBox("Please Enter A New Location", "Location Change")
Me.Refresh
I have tried this and several variations of it, as well as 6 days of searching various websites and can't quite find the hint that I am looking for.
If anyone can point me in the right direction, it would be greatly appreciated.

DefaultValue is a text, so you need quotes - and the straight syntax:
Me!txtLocation.DefaultValue = """" & InputBox("Please Enter A New Location", "Location Change") & """"

Related

Is it possible to show all options in Tokenize2?

Tokenize2 is a javacsript lib to select multiple options.
It provides a very neat UI to start writing and then get a list of options to select from. Selected options will show up as "tags" that can be removed with "x" link.
So far all is fine. But Right now you need to know what your looking for and start write at least one character to see matching alternatives.
In my scenario there are very few alternatives and they are not known to the user. I would like to show ALL options when the user clicks the input box. There is a configuration option named searchMinLength but it is already set to 0.
Is there a workaround that can be used? Maybe like triggering load and dropdown manually?
I know there are a lot of similar alternatives but I picked Tokenize2 because:
It looks clean and nice
It works in mobile browsers
I don't know if there is an "official" approach, but after some investigation I have found an acceptable workaround.
After downloading the Tokenizer2 sourceode I found the following line that triggered my attention:
if(this.input.val().length > 0){
this.trigger('tokenize:search', [this.input.val()]);
}
My interpretation is that the internal search command is not triggered unless the user input has at least one character. This line in sourcecode could easily be modified. I have filed a suggestion for this here: https://github.com/zellerda/Tokenize2/issues/26
My current workaround is to add an event listener for the select event and there trigger the internal search command. That works fine for my scenario and does not force a source code rewrite.
$("#my-dropdown").on("tokenize:select", function (e: Event, routedEvent: boolean) {
$("#my-dropdown").trigger('tokenize:search', "");
});
Tokenize2
This link worked for me GitHub
$('.tokenize-sample-demo1').on('tokenize:select', function(container){
$(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
});

How to type text on text fields and click on a button using AutoIt

I have a JNLP file (say Test.jnlp). I have opened that file using AutoIt. My code for opening Test.jnlp file:
$d = "D:\Ripon\"
$f = "Test.jnlp"
Run("cmd /c " & " """ & $d & $f & """ ", "", #SW_HIDE)
After opening .jnlp file a Login screen comes. My requirement is to type Username and Password -> Click Login button.
As I couldn't find the identity of elements (text fields, button) I failed to do that. Please help me.
There are a few types of GUI that don't give you ids for controls, almost all Java toolkits are an example of that.
There are several methods of automating them still:
Assuming the window is always the same size (which is often a pretty safe assumption to make) then AutoIt will allow you to click the window at a given position, or send text just to that window. For example in the above case you could try the following code:
ControlSend("Window Title", "", "", "MyUsername{TAB}MyPassword{ENTER}")
Another solution is using accessibility features. If you google 'autoit java accessibility bridge' I'm sure you'll get some results like this one. I've never tried this personally.
There is also a java access bridge no idea how this works either, but other people have been using it for a while.
As a last resort, you have to mimic user mouse and keyboard actions. This really isn't the best solution but at least you can be very sure it will work.
The following snippet of code should work:
Send("username")
Send("{TAB}")
Send("password")
Send("{ENTER}")

How to detect if an ASP ComboBox is blank.empty

I have an ASP ComboBox that is populated on page load with a list of information and a selected index is set. I want the user to be able to type a new value into the box and run a routine that saves that value.
So far, I've managed to set it so when you run the save routine it can detect the text of the box using;
cboFreeBody.SelectedItem.Text
If the box loads with 'arm' and I change it to 'leg', when I run my routine it grabs the new value and processes it, however if I delete 'arm' and leave it blank when I run the routine the above code returns 'arm', where I'd expect it to return ''.
I'm sorry if I haven't explained myself fully here, I'm rather new to ASP and VB.NET so I'm probably just splurting useless information here, but any help would be greatly appreciated.
I ma not sure but thats might help you..
If com_box.SelectedItem = vbEmpty Then
MsgBox("its empty")
End If
I use the isnullorwhitespace function usually.
if string.isnullorwhitespace(cboFreeBody.SelectedItem.Text) then
else
end if

VB.Net PayPal Integration Description

I am working with a historical PayPal system in vb.net. I am struggling to add individual item descriptions or names for the products that the user is paying for. It is using the NVPSetExpressCheckout and the data is meant to display on the PayPal website when the user is about to pay. Instead however I am getting constant issues which I assume must be due to syntax or just the way I am trying to do it.
Here is the current code which works:
Dim ppSet As New NvpSetExpressCheckout()
ppSet.Add(NvpSetExpressCheckout.Request._AMT, Decimal.Parse(litTotal.Text))
ppSet.Add(NvpSetExpressCheckout.Request.CURRENCYCODE, "GBP")
Dim basePath As String = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, String.Empty) + Request.ApplicationPath
ppSet.Add(NvpSetExpressCheckout.Request._RETURNURL, basePath & "paypal.aspx")
ppSet.Add(NvpSetExpressCheckout.Request._CANCELURL, basePath & "cancel.aspx")
I have then tried to add the a description using many methods such as:
ppSet.Add(NvpSetExpressCheckout.Request.L_DESC0, "First Item")
I however am simply getting errors like these:
'L_DESC0' is not a member of 'Encore.PayPal.Nvp.NvpSetExpressCheckout.Request'.
This issue is driving me mad and I can not find a fix. All documentation including the XML says that this is the correct way. I did try to just use the DESC field which worked however all the items just got displayed as one paragraph instead of being on separate lines. Help extremely appreciated.
Found the solution. It was due to the L_AMTn request not being submitted which is basically the item amounts. Once this adds up to the total cost it submits perfectly.

How to enter values to a text field using monkeyrunner

I am trying to enter some text to a text field in my android application using Monkeyrunner.
I wrote the code like this:
device.press('KEYCODE_BUTTON_SELECT',MonkeyDevice.DOWN_AND_UP)
device.press('KEYCODE_U','DOWN_AND_UP')
device.press('KEYCODE_S','DOWN_AND_UP')
device.press('KEYCODE_E','DOWN_AND_UP')
device.press('KEYCODE_R','DOWN_AND_UP')
while running the first line,the text field is getting selected.But The string "user" is not typing there.But the same code i can run out of my application ,In the android native search field i can enter "user" string using this code. I tried the same with device.type('USER') command also.That is also not working
If i am using this code
device.press ('KEYCODE_DPAD_CENTER', MonkeyDevice.DOWN_AND_UP)
It is taping one center button. (In my application page one button is there in the middle of the page.)
Try the following code. It's working in my case:
device.touch(x, y, MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.type('USER')
In the command touch put the coordinates of your edittext instead of x and y
One of the challenges would be to find the coordinates to touch, mainly using different screen sizes and configurations.
AndroidViewClient can help in this respect and you can avoid having to provide the coordinates for the Views and you can simply do:
subject = vc.findViewByIdOrRaise('id/subject')
subject.touch()
subject.type('AVCSample')
this lines were taken from one of the AVC examples: email-send.py
Do you have space character as part of the text you're trying to enter? Try without space and see if that works. Then, you can figure out how to deal with space.

Resources