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

Modules

Hello, I have a question on Modules. I have made some modules, but how do I apply those modules to my forms or queries?

Thank you
Sep 4 '08 #1
19 1417
missinglinq
3,532 Expert 2GB
If you're talking about a standard module, there is no "applying" it to a form or report. You can call any of the functions that reside inside your modules from code in forms or reports. Be aware that the module's name must not be the same as the name of any functions that it contains.

Linq ;0)>
Sep 4 '08 #2
If you're talking about a standard module, there is no "applying" it to a form or report. You can call any of the functions that reside inside your modules from code in forms or reports. Be aware that the module's name must not be the same as the name of any functions that it contains.

Linq ;0)>

Well I received a module converting an AS400 Date to regular date. The format of the date on AS400 is 1080904 would be today's date. I received the module converting that to 09/04/08, but it wont work. I wanted to know how to make that apply to my form.
Sep 4 '08 #3
missinglinq
3,532 Expert 2GB
You need to post the function within the module that's used to convert the date.

Linq ;0)>
Sep 4 '08 #4
NeoPa
32,556 Expert Mod 16PB
Any procedures in your modules must be declared as Public if they are to be called from outside of the same module.

If it's no more than 50 lines, consider posting the whole module and we can see what you're working with.
Sep 5 '08 #5
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Function DateConvert(InDate As Variant) As Date
  5. 'the purpose of this function is to convert the ADR7 date format into a regular date format
  6.  
  7. Dim NewDate As Date
  8.  
  9. If InDate = 0 Then GoTo EndLine
  10.  
  11. If InDate <> "" Then
  12.     If (Left(InDate, 1) = 1) Then
  13.         NewDate = Mid(InDate, 4, 2) & "/" & Mid(InDate, 6, 2) & "/20" & Mid(InDate, 2, 2)
  14.     Else
  15.         NewDate = Mid(InDate, 3, 2) & "/" & Mid(InDate, 5, 2) & "/19" & Mid(InDate, 1, 2)
  16.     End If
  17. Else
  18.     NewDate = "01/01/1900"
  19. End If
  20.  
  21. DateConvert = NewDate
  22.  
  23. EndLine:
  24.  
  25. End Function
Thank you
Sep 5 '08 #6
NeoPa
32,556 Expert Mod 16PB
If you change line #4 from
Expand|Select|Wrap|Line Numbers
  1. Function DateConvert(InDate As Variant) As Date
to
Expand|Select|Wrap|Line Numbers
  1. Public Function DateConvert(InDate As Variant) As Date
it should become visible to the rest of your project.

Good luck and welcome to Bytes! :)
Sep 5 '08 #7
I changed that, but do I have to name my dates as the date on the module?
Sep 5 '08 #8
Stewart Ross
2,545 Expert Mod 2GB
No! Like all procedures and functions, the variables used internally within the procedure or function are local to that procedure and have nothing whatsoever to do with other fields etc. You call the function by supplying a fieldname or value of the appropriate type as an argument to the function in its heading like this:
Expand|Select|Wrap|Line Numbers
  1. NewDate: DateConvert([yourAS400datefield])
or using the SQL equivalent
Expand|Select|Wrap|Line Numbers
  1. SELECT DateConvert([yourAS400datefield]) AS NewDate FROM YourTable ...
-Stewart
Sep 5 '08 #9
Where do I insert this line? I am not very familiar with Modules or Codes. Any help would be greatly appreciated.
Sep 5 '08 #10
NeoPa
32,556 Expert Mod 16PB
Well, where do you want to convert the format of your dates?

This is surely your starting point. We can't tell you that. You haven't even told us that yet.
Sep 5 '08 #11
I want to convert them on my forms and queries if possible.
Sep 5 '08 #12
NeoPa
32,556 Expert Mod 16PB
Freddie, your minimalist approach to answering questions is not going to help us to help you.

From the little you have said I can only say that these general places are where you want to call the function from.
Sep 5 '08 #13
My bad, I building a database through my as400 ODBC connection and the dates are in wrong format and I want to allow them to be in normal format which is why I inserted the Module, but it doesn't change on my forms and since I haven't used Modules much, I don't know where or how to make these modules work.
Sep 5 '08 #14
NeoPa
32,556 Expert Mod 16PB
Do you have an example of where you need an AS400 date to work as a converted one. Tell us what (and how) what you currently have refers to the date and we will see if we can provide a version which uses the converted date.

This could include the existing SQL for a query for instance, or some existing code, or even a TextBox on a form (this would not be updatable if the data is passed through the function of course).
Sep 5 '08 #15
Well I am using the date in a form. I have the date in a combo box in a query so that they choose the date on the combo box and it will report the data. They will not be able to modify or add any dates because they are linked to the AS400, but presenting them is where I would like them to be regular date.
Sep 5 '08 #16
Stewart Ross
2,545 Expert Mod 2GB
Hi freddie. If your combo's row source is a query then you need to alter the query to use a call to the function instead of a direct reference to the AS400 date field. The syntax of that call has already been posted in post # 9.

If you are linking your combo to the AS400 table directly you will need to change this to an Access query based on that table, using the same syntax as shown in post 9 for the computed field.

Neither of these steps is difficult to do - it should take less than a minute. I do feel that you must have very limited Access experience, however, because your answers show only limited understanding of what a function is, how code modules contain procedures and functions, and the calling conventions for their use in queries and so on. I can only suggest that you look up good introductory texts on Access, and review the sample Northwind database which comes with Access for pointers on how a small amount of VBA coding can be used to link forms together in useful ways for users.

-Stewart
Sep 5 '08 #17
Well I don't have much experience with Access, barely getting my feet wet. I have used Access, just not too much coding which is what I really want to get into. Do you have any boxes or websites you would recommend me to learn more about code?
Sep 5 '08 #18
Stewart Ross
2,545 Expert Mod 2GB
Hi freddie. There are some usful links in post 2 of this thread which may help you.

-Stewart
Sep 5 '08 #19
Great, Thank you! I appreciate the help!
Sep 5 '08 #20

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

Similar topics

2
by: Dave | last post by:
Hi Everyone, I am trying to import a package and then loop through the modules inside the package, but I'm running to a problem. Basically: ----- I have a package called...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
7
by: Jorgen Grahn | last post by:
I have a set of tests in different modules: test_foo.py, test_bar.py and so on. All of these use the simplest possible internal layout: a number of classes containing test*() methods, and the good...
4
by: Misto . | last post by:
Hi folks! Short: There is a way to dumplicate a module ? I tried copy.deepcopy(module) but hangs with an error (also with standard modules ).. The only solution that I have by now is...
2
by: James Buchanan | last post by:
Hi group, I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I have problems with make. configure runs fine and creates the makefile, but right at the end ends with an error...
7
by: Lauren Quantrell | last post by:
At running the risk of asking how big is too big... Is there a rule of thumb or a best practice that says I may have too many modules? I currently have a Access2K app with about 30 code modules,...
13
by: Robin Haswell | last post by:
Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules...
173
by: Zytan | last post by:
I've read the docs on this, but one thing was left unclear. It seems as though a Module does not have to be fully qualified. Is this the case? I have source that apparently shows this. Are...
3
by: Mohamed Yousef | last post by:
Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them (avoiding importing problems and Consicing code and...
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: 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
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...
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
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,...
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.