Setting the controlsource value of a listbox using Properties Window - forms

I am new to VBA and am currently still studying the most basic ideas of the language. I haven't gotten that far in my VBA Code studies to write the code I need by hand, so, in the mean time, I have been using the VBA Editor to enter Property Values via the Properties Window. This has been proving far more difficult than I anticipated. My Goal is to create a drop down list for a VBA Form. I understand one of my options is to reference a range of cells in my excel worksheet by inputting it into the value field located right of the ControlSource Property. My attempts to input the desired range always comes up with the same error:
Could not set the ControlSource Property. Invalid Property Value.
I have tried looking in the VBA Help files and even searched online. I haven't had any luck finding the proper syntax to enter into this field.
I am assuming I may run into similar issues as I try to set other property values through the Property Window. Thus, I am diligently studying my VBA courses so I can simply write the raw code. But that takes time and I need this form to work as soon as possible.
Is there anyone out there that wouldn't mind lending me their brain for a moment? I would be most grateful. Having this working would bring a lot of stress off of me.
Thanks for reading!

What tigeravatar mentioned, works fine for me, for the ComboBox as well for the ListBox.
If I enter =a1:b5 into the ComboBox' RowSource, I see the values of the cells if I open the form and the Combobox. Tigeravatar's notation with $ and sheet! may be more reliable for the productive version.
The RowSource is where the boxes get their displayed items from. The ControlSource is where the chosen value finally is linked to. So if I write just A10 to the ControlSource, then open the form, then pick a value, close the form, I see the chosen value filled to the Excelsheet field A10.
Sometimes it helps to start a fresh UserForm and to add some simple fresh controls. If you seek around, you will probably alter property values that influence the behaviour in an unexpected way, and then you get lost. I have tested with Office 2010. If you have another version, it may be important to forum readers to know.

Related

cfinsert is picking up my search input field in a different form

When I submit my form I am getting an error from my cfinsert function because there is not a database column name "SEARCHFIELD". The problem is "SEARCHFIELD" is not an input in the form I am submitting.
Both forms have close and open tags so I am not sure why my search form input is being referenced in my main forms submission?
Any thoughts?
Two ways I can think of to avoid this, without seeing your actual code it is hard to guess where SEARCHFIELD is coming from. As some of the comments pointed out it would most likely be from a CFPARAM or the name of your submit button in the form.
The first way you could tackle this is the CFINSERT tag has an attribute named formfields where you can list off the columns you wish to insert with. You can see that here in this doc link:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c78.html
Another way you could do this is you could add code to remove SEARCHFIELD from the FORM scope prior to running the CFINSERT. Which would be as simple as:
<cfset StructDelete(FORM, "SEARCHFIELD") />
You could check to see if it exists and if so then delete it but the StructDelete() will run without issues even if the field does not exist.
I personally do not use CFINSERT/CFUPDATE and I know the default opinion in the community is not to. They do have some benefits though that often are overlooked in that they do parameterise the SQL and offer at least some safety from malicious people. Without knowing anything about what you are doing it is hard to say if using them is actually a shot in your foot in the long run or something just fine to be doing.

Alter input of form before it is submitted

I'm creating a multilingual Drupal site and trying to implement a search function, that only displays results in the current language, that the user is viewing the site through.
Using Drupals own searchfunction at /search/node it is possible to select which language to search for through the "Advanced search" options, and it works perfectly. However, I dont want to expose these language selectboxes, I just want it to only search in the current language automatically.
What's the best option to do this?
I have one solution where I create a hook_form_alter function, that sets the #default_value in the language selectboxes to the current language, and then I hide the whole "advanced options" with in css. This doesnt seem very right though.
I think the most clean solution would be to hook into Drupals form-processing process and append ex "language:en" to the input text, but I cannot get this to work.
Does anyone know if it is possible via one of the Drupal form related alter functions, to get a hold of the input text and alter it before drupal does its final processing of it?
To answer your question specifically, while using 'hook_form_alter', you have a referenced variable called '$form_state'. This stores the values in the form, and any change there will be passed further.
Also,
I think setting a default value and hiding the field is a good solution as any, only, if you are hiding it you should do it server side, while altering the form. The same field you are setting the default value to. like this:
$fieldname['#type'] = 'hidden'.

MS Word 2007 - How to set up placeholder text to mimic text but not formatting

I'm probably biting off more than I can chew with this particular problem, but I'll try to be as specific as possible in case it's within my scope. Disclaimer: I'm not terribly experienced with MS Word, beyond simple data entry/some formatting, and I have absolutely zero experience working with macros or VBasic. Unfortunately, I'm afraid the solution to my problem will come in the form of one of those last two.
THE GOAL:
What I want to do is to have placeholder text throughout my template document that will change content but not formatting when the first instance of it is changed. Basically, I'm writing a template for support manuals for a software suite. Each app has certain similar features like the menu bar, data entry screen, diagnostic log screen, transaction history, etc., so I am pre-writing those sections and using placeholders when I need to insert certain app specific properties.
I started off using the Insert->Quick Parts->Document Property->Subject tool which I used as a placeholder for the app name. I set the Property to [Subject] and then used Insert->Quick Parts->Field->Subject throughout the document, wherever I needed to include the app name. This worked fine in this case because the app name will always be capitalized. I simply change the text in the first [Subject] (which is content controlled) and update the fields throughout the document, and they all match nicely, easy-peasy, work done, go home and drink beer, right?
Not quite.
Our software handles part tracking via scanners and SQL Server, so while the interface and menu in the apps remains largely unchanged, the parts they track change from app to app. Because of this, I need to change the part name when I reference it within the text of the manuals; for example, if I'm working in ToiletPap.app and our TP is tracked by the roll, I need every mention of [Component] to be changed to roll. If I'm working in LightBulbs.app, I need [Component] to say bulb.
My first efforts went toward creating a custom doc property called Component using the Advanced tab under the Document Properties dropmenu. I then created a plaintext content control around my first [Component] titled Component and made my next [Component] a field with modified code: {COMPONENT * MERGEFORMAT}. This comes from copying what I can find when [Subject] works. This didn't work at all; updating the text in the first CC doesn't change the Content doc prop, and my fields return "!Undefined Bookmark, COMPONENT".
I got close to what I need by using the [Comments] doc property, set initially to [Component]. I used it just like [Subject], but (this is when I realized that capitalization was going to be an issue) when I mention my [component] in-text, as often as not, I need to to be lowercase instead of upper.
I've looked on MS's forums and a few others as well as here on SO, and I can't find anyone who's trying to do the same thing, much less an answer to how. Please keep in mind when answering, it would be a great help to me if you would include step-by-step instructions on how to enter/implement the code you provide because, as I mentioned, I have no idea how to go about editing macros/VBasic for MS Word.
To restate and summarize my overall question: How can I use a placeholder that displays the text "[Component]" so that, when I change the first instance of [Component] to something else, say "hopper", every subsequent instance of [Component] is updated to hopper but maintains its current capitalization and formatting scheme?
Apologies for the length of the request, but I wanted to make sure I explained the situation as accurately as possible. Thanks in advance for your consideration and responses.
I managed to solve this one after a couple extra hours of tinkering. I didn't need macros or VBasic, either.
On the first instance of [component] I created a plain-text content control to act as a container (not a necessity, but it makes it look nicer. Will likely cause a problem eventually, but for now, it's working as intended) and bookmarked it. Then, for all other instances of [container] I selected each and used Insert->Quick Parts->Field->Ref with the following field code:
REF Text1 \*Lower
Where "Text1" is my bookmark and "*Lower" indicates all lower case. The *Lower can be replaced with *Upper or *FirstCap to indicate all upper case or capitalize the first letter respectively. Now, each field reflects the text of the first with the capitalization appropriate to each field's location within the document. Just like using the doc prop with [Subject], ^a -> f9 is needed to update all fields within the document.

cakephp empty option for select fields

I am stumped beyond belief.
I have a select box being generated by the cakephp form helper. I am feeding it an array of options, and passing an empty value... pretty standard stuff.
However, my "empty" field is showing up at the very bottom of the list.. not the top. So when the field loads, it just defaults to the first option... which is not the "empty" option.
Not a whole lot of room for error on the code here..
echo $this->Form->input('whatever',array('empty'=>'Choose One','options'=>$categories));
The only small item that might be important, is that $categories is a multi-array, so the select box has optgroups & options.
Is there some quirk/bug out there that I do not know of that is trying to force me to sneak into my scotch supply a few hours ahead of schedule?
edit: using the latest release of cakephp 1.3.x
I think that I once had the same problem.
It turned out to be the data (options array).
Is there an option with an empty key? probably the last one then.
this lead to the scenario I remember and seems to be the exact same thing.
the form helper will override this empty key value pair then and not create a second one.
without more infos from your end this will be difficult to solve.

Get form field value via module [VBA]

I have a program built with VBA, in access.
I have a form with the field chDate and I need to get the value of the field in a module file named Global (not class module).
I tried to access it but I think I get empty value, string. not error.
I'm no expert with VBA, its new to me (I have experience with VBS).
Can someone please help me and tell me how can I access the value of a form field via module file?
Thanks!
If you can provide some sample code, it might help us in trying to get you a solution.
Here's what might work:
Dim an object as an instance of your form, and set the instance to a new instance. These two lines will do that (assuming the form is called frmForm)
Dim theForm as frmForm
Set theForm = new frmForm
then Show that Form:
theForm.show
The form will get the focus, so you can populate the fields. At that point, once the form is hidden, your code should be able to pull the field as such:
var1 = theForm.txtFormField.Text
However, if you unload the form in code, all variables directly tied to the form will be lost. In that case, you might want to follow Oneide's example, and set a global variable to the value of the form field. You can do this in one of the form's event handlers.
Let me see if I can recall my Access days. In your global module you should access the form field be prefixing the form name i.e.
var1 = Form1.txtFirmField.Text
As far as I know, you're trying to get the data the wrong way.
Anytime you would try to get your form data, from a standard module, your form probably will already be closed or, if you're not opening it as a restricted window, the value will not be ready yet.
Anyway, if you could get pass through all the difficulties above, you're probably coding in a not standard / right way.
Remember that VBA is an event driven language, and you would be better using it's strenghts rather than fighting against them.
As a final word, if this is just a casual coding, I suggest you using a global variable and make de Code Behind Form have set it up on control's change event.
If you're not sure what I mean, please leave a comment and I'll try to explain it better.
And, if you don't mind, let us know more about your starting code to get better answers.