473,387 Members | 1,757 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,387 software developers and data experts.

Return form value from a custom module

maxamis4
295 Expert 100+
Hello folks,I am playing with a new function that will loop through every control. In addition to looping through the forms controls I want to obtain the value of that the control has. That is where I am having problems. I can loop through the controls but I can not get the values from the forms:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Function AuditCheck(frm As Form)
  3.  
  4. Dim setformvalue As String
  5. Dim ctl As Control
  6.  
  7. For Each ctl In frm
  8.     If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acListBox Then
  9.  
  10.         mytemp = ctl.Name
  11.  
  12. LINE 1 ------->  'setformvalue = Forms![frm_Admin_employee]![txt_empid]
  13.  
  14. LINE 2 ------->  setformvalue = frm.Controls.ctl.Name
  15.  
  16.     End If
  17. Next ctl
  18. Set ctl = Nothing
  19. End Function
  20.  
  21.  
As you can see i have to examples of setformvalue. The first example in Line 1 works but I have to specify the form and control manually. What I am trying to do with Line 2 is use the automated method in the form loop to get the control (which works) and then figure out the syntax on how to duplicate Line 1 problematically in Line 2.
Jun 18 '12 #1

✓ answered by maxamis4

Have figured out the fix here is the line syntax needed:

Expand|Select|Wrap|Line Numbers
  1. setformvalue = Forms(frm.Name).Controls(setformvalue).Value

4 1870
maxamis4
295 Expert 100+
Have figured out the fix here is the line syntax needed:

Expand|Select|Wrap|Line Numbers
  1. setformvalue = Forms(frm.Name).Controls(setformvalue).Value
Jun 18 '12 #2
TheSmileyCoder
2,322 Expert Mod 2GB
It would be alot simpler to use:
Expand|Select|Wrap|Line Numbers
  1. setformvalue=ctl.Value
Jun 18 '12 #3
maxamis4
295 Expert 100+
I actually tried that before I posted and it does not work. Any ideas why?
Jun 19 '12 #4
TheSmileyCoder
2,322 Expert Mod 2GB
It should work, so You will need to be more specific in regards to which way it doesn't work. Is it giving you an error, and if so, what is the error(nr and description)? Is nothing happening?


Things I could imagine happening is if the control value is null, that the code would complain. That however should be no different from the approach you say is working.

Or if you used "my" approach before you added the check to see if its a textbox/combobox/listbox.
Jun 19 '12 #5

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

Similar topics

6
by: David | last post by:
Ok. Can PHP control a form value directly? Eg. like the javascript "document.Form1.text01.value = "Y"". Eg. allow me to put a value into a form text field on page load. Either I missed this in...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
4
by: Dmitry Duginov | last post by:
Hi, Can anybody recommend a custom module for DotnetNuke, implementing different kinds of surveys? The standard "Survey" module is too simple and it doesn't cover different real life scenarios....
0
by: Umut Tezduyar | last post by:
This post is related with .Net 1.1. I have written my custom module by inheriting IHttpModule. I realized that, at the first compile, framework creates the instance of my module and then caches...
9
by: Ale K. | last post by:
What's the best way to make a form return a value.... i want to try to avoid using module variables for doing this... Thanks. Alex.
1
by: Brian Leach Christensen | last post by:
Hi. I have a problem with making my form return a value. when a datagrid cell is selected it selects the entire row and copies the the value of the first cell into a variable. now i need to make...
6
by: johnnyG | last post by:
Greetings, Since Main() is a subroutine in VB.NET console apps and not a function, is there a way to return a value to a script ro other "caller" for a VB.NET console .exe? sub main() like if...
4
by: duffdevice | last post by:
Hi, I came across this unexpected behavior while working on something else. I am attempting to return a custom type by value from a global function. I have a trace in the custom class's copy...
6
by: tmb | last post by:
I have a page with many dynamically created HtmlSelect controls which i create in the Page_Load function. Sometimes upon a post i need to change the selected items in some of the controls depending...
5
by: jose1lm | last post by:
What is supposed to happen: A user enters data into one of the FORM input selections. When the user submits the form, the onclick event is supposed to go to a function that will set another FORM...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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...

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.