473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check fields from hidden form and change data on original form

31 New Member
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 1354
Stewart Ross
2,545 Recognized Expert Moderator Specialist
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
16158
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? 1) simply UPDATING the values for all fields in the table, whether or not any particular field has actually changed 2) running a second SELECT statement and comparing the $_POST vars to the returned values, and only UPDATING those that have...
27
7111
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 a user from information you got from the session. Each secure app on a site must challenge the user for name and password, each and every time the user accesses it (not just once and then store it in the session). If a secure app is multi-page,...
3
2779
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" to be checked as all primary contacts must be standard contacts. If I uncheck the primary contact no change in status of the standard contact is needed. I am assuming I can use some onclick function but I tried using a onclick on the one box to...
9
4224
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 - however my question is, which is more performance effective, or easier on a clients resources? I mean - if I have several <input type=hidden> tags with my values that I can reference, would this have a greater overhead then, for example, having an...
24
2711
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 wondering if there are any best-parctices for optimizing or mitigating the risk of using them. Here's what one table looks like: NoteText - Memo NoteDate - Date/Time (indexed, dupes ok) NoteBrief - Text (length = 254) Entity_ID - (Long,...
5
2342
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 on the page, does some processing, populates the <ASP: hidden fields, and then I need to redirect to another page, where I want access to these fields. I suspect that these have to be inside a form, but figured I should ask. I'd use a Cache or...
4
1397
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 new form field data. How can I achieve that? Thanks. <form name="form1" method="post" action="<?php echo $_SERVER."?".$_SERVER; ?>"> <table> <tr>
3
2303
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) then a new submit option. My question at this point would be what logic or commands would I use to compare the original data in the fields to what's being submitted. I ultimately want to preserve the original records and somehow append
4
2121
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 putting the whole form in a set of <div> tags and the form now collapses after they click submit. Perfect!! But, have set some mandatory fields using java, and I need to it validate the these fields before it collapses the form - otherwise it says...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.