473,394 Members | 1,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Check fields from hidden form and change data on original form

Ok, so i looked up the information that i needed, but now I see that what i was trying to do was really made for a SQL statement.

Here is what happens. I open a form (hidden) with 20+ fields on it. Any of the fields may have a term on it. (MPI or LPI) <-- text obviously. If they exist in any of the fields, then i need to make a label visible on the form that is actually going to be used. Then the hidden form closes.

The code i tried unsuccesfully to use looked like this

Expand|Select|Wrap|Line Numbers
  1.  
  2. if [op1] like (*MPI*) or if [op2] like (*MPI*) then
  3. forms!otherform.label = true
  4. end if
  5. if [op1] like (*LPI*) or if [op2] like (*LPI*) then
  6. forms!otherform.label2 = true
  7. end if
  8.  
the only time it worked is when i made it look like this
Expand|Select|Wrap|Line Numbers
  1.  
  2. if [op1] like (*) then
  3.  
But of course then it doesnt matter what is in the field.
Is there a way to accomplish what i am doing. I am sure that there is a complicated method of doing it..... I am also quite sure that i am not doing it very efficiently, but I try to actually learn how to read the code that i use, so that i will learn it. So the easier the better :), but if complicated is the only way, then complicated it is. Thanks in advance.
Jan 30 '09 #1
1 1340
Stewart Ross
2,545 Expert Mod 2GB
Hi. If you want to compare string control values to string literal text values you need to enclose the string literals in double quotes:

Expand|Select|Wrap|Line Numbers
  1. if ([op1] like "*LPI*") OR ([op1] like "*DPI*") then
  2.    ...
  3. End If
(see our insight article Quotes and Double Quotes - Where and When to Use Them for more on this.)

The use of the wildcard character "*" before and after the pattern allows you to find any occurrence of the given pattern within any other characters in the string - for example "Printer; DPI". You would not need the wildcards before and after the pattern if it is never preceded by or followed by other characters in your string, but you don't say whether or not this would apply in your case.

With 20 controls in your hidden form you are likely to end up with a lot of IF statements. There are more efficient ways to process these, depending on how you name the controls and what you are doing with them. One way is to ensure that they are named, say, Op1, Op2, Op3..Op20. These can then be processed in a loop, like this:

Expand|Select|Wrap|Line Numbers
  1. Dim strCtrlName as String
  2. Dim intCtrlNo as Integer
  3. Dim varCtrlValue as Variant
  4. For intCtrlNo = 1 to 20
  5.     strCtrlName = "Op" & intCtrlNo ' this just concatenates the control name with the number to form Op1, Op2 etc
  6.     varCtrlValue =  me.controls(strCtrlName)
  7.     if not IsNull(varCtrlValue) then
  8.        if (varCtrlValue like "*DPI*) or (varCtrlValue like "*LPI*) then
  9.          <do stuff>
  10.        end if
  11.     end if 
  12. Next intCtrlNo
There are many possibilities - I am sure there are other approaches that would work just as well that others could think of.

-Stewart
Jan 31 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
3
by: Rich | last post by:
I have a form with 2 check boxes. One of the check boxes is used to specify that the user is a "primary contact." When I check the primary contact box I want a second box for "standard contact"...
9
by: Randell D. | last post by:
Folks, I have a large amount of values to store (we're talking tens, if not hundreds of bytes). I need this for a client side application - ignore the security consequences for the moment -...
24
by: deko | last post by:
I have an mdb (2002 file format) that uses memo fields extensively. I've read a lot about how problematic memo fields can be and that avoiding them is a good idea. But I'm stuck with them and was...
5
by: HockeyFan | last post by:
I know that <input type="hidden" fields are used within a form, but do <ASP:HiddenField s have to be in a form to be used? I've got a VB-based (codebehind) that catches the click event of a button...
4
by: mickey | last post by:
I have a form like the one below. Upon submit I would like to self post to the same page but have the original $_POST data( which was posted to this page from another ) also be sent along with the...
3
by: bvlmv | last post by:
Greetings, I have a simple html/asp form that submits data to an access DB. The idea is when calling a record back from the db, the page will have an option to change certain fields (drop down)...
4
by: plumba | last post by:
Let me explain.... I have a form (most of which you guys have helped me with!!). The initial problem I was having is that it was holding the data in the fields after submit, I resolved this by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.