Modules & VBA :: Standard Way Of Declaring Constants?
Mar 11, 2014
I know that a public constant is available to all subs and modules. I also know that you can only declare these in a module, you can't for example declare these in the form.
So how what is the best way of declaring them?
At the moment I just have a module that has nothing else except for the 3-4 constants that I use throughout all my forms. Is that ok?
I just realized that I do not know where my ShellAndWait module is obtaining the constant definitions for the WindowStyle arg. They are all defined presently:
However, I would sort of like to know where the constants are actually defined that support my ShellAndWait VBA Module. I do not like relying on "osmosis"!
I have a form which has a button to email the data out in a standard email message.
Private Sub Command60_Click() Dim MyDb As dao.Database Dim rsEmail As dao.Recordset Dim sToName As String Dim sSubject As String Dim sMessageBody As String
[code]...
This works well enough, however, FIELDS 11 through to 16 contain the venue address. This is all we ll and good if every field of the venue address is populated. here are times when not all of the fields are populated, for instance, the address might only be 5 lines.I know I can do this using IIf statements on a report, but how can i achieve the same thing for the email.
I have a Row source string which I use quite often. Currently, I declare it in each procedure and copy and paste it in. The problem is when it needs changing, I need to change it in a billion places.
can I declare the string as public and set it as public too so that I can just make a reference to it rather than copy and paste entire slabs of code into each event??
I am using Brinkster to do some ASP/MS ACCESS programming.
I need to add a field which increments automatically with every insert into the table. I tried the following statement: ALTER TABLE Jobs ADD jobid AutoNumber(4)
In one record (or row?) there I have 10 fields (columns), how can i find the standard deviation of those 10 numbers. Seems to only want to be able to do standard deviation if all data is in one field or column. I tried doing a query but same thing, if all the fields are across, it doesatn find the standard deviation of them. Please help this worthless access user. Thank you, I look foward to all the help I can get. As you can see, I still am struggling with even terminology. Excel is easy to me, access is a challenge to say the least.
the standard value for the yes/no datatype = no..I try to set the standard value to yes but I can not be allowed for yes ? how do I set it to yes ? I have open the table, then I could not change to yes.
I have a combo box which is used to find a record on the form. I have set LimitToList = Yes and put in code for the event NotInList.
My problem is that my code is working fine allowing me to produce my own message, but then the standard message appears as well saying "The text you entered is not an item in the list"
:rolleyes: I have a note field in a table for short description of a building parts. Is it posseble to make some standard text in a form with a "values" between the text to choose from? Like: This building is from "text field for input" The roof is made of "a combobox with 4-5 items to choose from".
The standard text with the choosen values should then be sent to a note field at submit.
Like: This building is from 1945 The roof is made of tegl
From a form build a report using standard paragraphs using a combo or list box . Paragraphs may vary in length but must format correctly on the report. NO SPACES MUST BE LEFT BETWEEN PARAGRAPHS. Also the form must allow editing of the standard paragraph. ie where there is perhaps a change of name etc: ALSO is it possible to exceed the 255 characters in a text box ?
Hi I am getting fed up of repeatedly modifying the basic new form in Access 2003 since I hate Tahoma and I never want dividing lines and I always want the VBA to be Option Explicit and I have my own ideas on colour schemes etc. etc. Every new form I enter I have to make all the changes manually and simply wondered if I am being an ass. I can modify templates in Word and Excel so if I could do the same thing in Access I could save myself cumulative hours of work. I cannot seem to find anything so does everyone else bow to what Microsoft think a form should look like or do you all do what I do and endlessly recreate the same starting point for each form??? Any pointers would be 110% wonderful!! Best wishes
I need to restrict the random autonumber feature to 10 digits and a positive number for a primary key. I work in the medical field, and HIPAA privacy regulations require the use of random ID numbers to identify records. Also, I need the numbers to be positive numbers because we will be using barcode scanning equipment and the possibility of truncating the negative identifier creates the possibility (admittedly remote) of having a duplicate PK barcodes. I understand that we cannot change the Access feature, but any VBA code to generate a truly random 10 digit positive number I can use as a PK?
I am trying to create a query that filters results only outside of 1 standard deviation of the mean. Is there an option for this in the criteria spot? I'm fairly new to Access and I'm not sure if I can reference a particular cell in the criteria.
I've built a system with around 20 tables in it. All of these use the standard ID field offered by default by Access as the primary key. A friend with a background in database design and development for large corporates using Oracle has reviewed the database (he is going to do some VBA programming for me) and suggested that we use more appropriate primary keys based on data attributes.
He has read "somewhere" that there are problems with the standard ID fields and that occasionally the fields are renumbered/reindexed and that this can cause problems. There are a fair number of queries and some complex forms which will need to be updated for these changes but it would be a shame to go through all this work if it isn't really.
Should we use the standard Access IDs and is it worth a chunk of effort to change from where we are now?
I have generated a standard form for displaying/editing of data and I have also created a form for generating Sql query statements (The form builds a string but does not execute the query). Can I execute a query and use it with that form.
So when I generate the the SQL statement and execute the query it loads the form (With Data) instead of a query datasheet. Thank you.
I am filling in a database using forms, and I would like to be able to add standard values to any field using a macro/VBA code I don't want to set up a different macro for each field though - I have around 40 different fields (to elaborate, it's a mark database for student projects, each field is a different thing I am commenting on. I want to quickly add 'Missing' or 'Good' to a field - but I also want the option of free text instead.).can't figure how to do it in MS Access.
I have been using a table with queries with no problems. Now the queries wont recognize the last two records of the table when doing a Count. there are no null or empty spaces. I am using the drop down access standard menu to place the "Count" command. Is there a solution to this problem ?
I'm wondering how other members here make decisions whether they want to place codes behind form or use a standard module instead.
I understand there is a performance penalty when you add another module (and use it), but am not sure whether one big fat module would be faster than several smaller modules with identical coding.
Furthermore, I know that some members use a hidden form to deal with startup and shutdown processing. Sometimes the processing has nothing to do with forms and would make more sense in a standard module, but since the form is already loaded, does it makes more sense to use the module behind the form than calling a function in a separate standard module to execute the needed code?
I’m new to Access and have been looking through a lot of the sample db,s very helpful, am I right in my conclusion that there is a lot of work being carried out in VB in the modules. I’m reading all sorts of books at the moment and they are not going any ware near this area. Is this the new 2003 program getting to grips:)
I am getting an error with the Me function if present in modules. Is this because a module is Public? How can I fix this problem and make the code run in a module? Thank you.
This code runs an append query before closing a form named form1 and open another form named form2 using the c/n as linking criteria.
I am getting the error with Me.
I am trying to run this module from a menu bar.
thank you for you help.
Dim mydb As DAO.Database, MyRs As DAO.Recordset Dim strCode As String Dim strFilter As String Dim stDocName As String Dim stLinkCriteria As String
Set mydb = CurrentDb Set MyRs = mydb.OpenRecordset("list")
Hi guys, im working on a project whereby a Visual Basic module has been designed in MS Access to email out a RTF document attachment of reports to shift managers when they have hazard items not closed in their area. Im building an ASP front-end to the database and would like to incorporate a button to do the mailout, however i dont know how i can link it to fire the code when the button is pressed. Is it even possible?