Whether To Code In A Form Module Or A Standard Module?
Dec 14, 2007
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 am creating an form in a database and whenever one of my procedure's run it creates this error message:
The expression ON Load you entered as the event property setting produced the following error: Member already exists in an object module from which this object module derives.
*The expression may not result in the name of a macro, the name of a user-defined function, or [event Procedure]. *There may have been an error evaluating the function, event, or macro.
just wondering why randomly certain modules in the form code stop working..
when you accidentally press return.. or do something in the wrong order.. or apply one rule to one control.. and then another control rule stops working..
so you have to delete the code.. right click on the control's event.. and re-insert the code into the event section.. and then it works..
Does your Tools Reference have an MS Office 15.0 Object Library?
Just had to share this strange occurrence in the VB Code Module:
I use breakpoints all the time, was just using them yesterday.
Noticed that some events seemed to act differently this morning. The front-end was approaching 88 MB (after compress) so it is time for a change anyway.
Created a new blank Access dB (Access 2010) and imported all objects from my last backup revision. Reset the home page and tools References. Matched the settings side by side. As usual, the database shrank from 88 MB to 60 MB. The import all objects will usually compress things about this much.
From the screen shot, put breakpoints in previous code, added a new Lost-focus event and added a message box. None of the breakpoints work. The message box fires on the lost_focus and all of the code in the Click event works fine. But, not a single break point would work.
Totally powered down and restarted the Windows 7 32 bit Enterprise workstation. Still no change.
Took the screen shot of Tool-References from the code module of a two week old archive version. Used it to evaluate my new imported object database.To my surprise, the Microsoft Office 14.0 Object library is now Microsoft Office 15.0 Object Library.Also put all the objects back in the same order. Saved and closed the new imported object database.Now, the breakpoints work just fine.
I had failed to reference the Office 15 Object Library and the VBA Extensibility 5.Office 14 Object Library is nowhere to be found except on my 2 week old backup archive.
Is this a Microsoft auto update? Is this what drives the breakpoint in the code module?
I am in Acess2000 and trying to go to put vb in. When I hit the code icon, I get the message: "name of db" failed to create the VB module '|'.
Is anyone familiar with this message and what do I need to do. I just added this form, and in the other forms that have vb code already, I can get to them okay.
Is the calling Form name or the event handler's sub name available in called module? I need it in order to determine the form's name as in [Forms]!someformname!some control.
You know, when I create a new form and add a button to it. Then I add a new module and entered a public Sub in it. Once I switch back to the new form, I typed this below..
Code:Dim sTest as basTest
I noticed there is no "basTest" in the intellisense. Why? I kept getting a compiler error saying "A module is not a valid type". What do I need to do to fix that? I'm at loss on what's the problem is.
I have three forms - Form1,Form2 and Form3 linked to a navigation form with Navigation buttons. I have separate VBA codes under each Before update event of these forms, Form1,Form2 and Form3 to call a VBA module to track the changes performed by the users(Like an Audit Trail) in specified fields of the forms which will track them to a table.there are control tags in the form properties --> others --> Tag to track the changes in the fields which are defined in the VBA Module.this is the code to call the VBA Module:
Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.NewRecord Then Call AuditChanges("UniqueID", "Part No", "NEW") Else Call AuditChanges("UniqueID", "Part No", "EDIT") End If End Sub
[code]....
The code is working perfect when the forms are run separately.but when they are run from the navigation form by clicking the navigation buttons, the code is not working !!
I have this code below that is working however the calculation are updating on my form late.
Basically, I have some calculation that are performed on a "After Update" event on some controls on my form. I wanted it to do the calculation after I update the control on the form.
The code is in a module and I just call the function after update on the control But the form is not updating when I change the value in a field. I have to change the field again for it to update.
Control
Code: Call GeraAuditCalc DoCmd.RefreshRecord
Function
Code: Function GeraAuditCalc() Dim fHrs As Double Dim Ttl As Double Dim Ttl1 As Double Dim Ttl2 As Double
Is there a limit to the number of fucntions/suroutines in a Form's module. I got an overflowerror when compiling and I moved a fucntion from the Forms mdoule to another module and the error did not re-appear.
I am trying to create a customizable report that would allow the users to choose fields. I have a pretty common code that I found online and adapted it, but it fails on the first SetReportControl function.
The error reads: Run-time error 2465: Application-defined or object-defined error
Could it be something as simple as an incorrect reference? I have checked multiple times, but I am stumped.
Code: Option Compare Database Option Explicit Sub MakeReport()
[Code].....
This is a trial run, in the end I need to be able to open a report, then adjust the Report controls within 1 or more subreports inside the main report. That is a battle for another day.
I have a button on a form which calls a module to show a calendar form. The user picks date and time, and saves it. The calendar form closes and adds the date and time to a text box on the initial form.I want to save the record so that the underlying table/query is updated, but it's not working. The record is not saved until the initial form is closed.Here's the form vba...
Code:
Option Compare Database Option Explicit Private blnFlag As Boolean, blnSaveIt As Boolean Private Sub btnDelete_Click() On Error GoTo Err_btnDelete_Click
I'm working on the Navigation Form template in Access 2010, which is new to me. It appears that one needs to use the BrowseTo command to open up a form in the built-in subform module. I'm trying to create a couple of buttons where each button opens a form in a different data mode; one in read-only and one in add mode. Here is the syntax I used for read-only:
frmSales is the Sales form I want both of the buttons to open and frmNavigation is the Navigation form. It seems to be ignoring the data mode part at the end however. It only will open in Edit mode. Is there something I'm doing wrong with this command?
Hi, I hope someone can help. I know there are masses of threads on security but I can't find one that is similar to my problem.
I have a SQL 2005 database that uses an access front end AND an intranet front end, dependent on the user.
I need to write a security module to run both so that whether a user is on the access version or the intranet version the security will remain the same. The security will be maintained from within forms in access.
Has anyone done something similar or seen any articles on something like this that will help me.
I have a bunch of Forms set up in Access that are updating tables etc......
At present 100% of the code is sitting on the Form. I have some code that is repeated because of a string parsing issue. What I am thinking of doing is writing this code as a couple modules and then call them when needed.
Does that make sense to write them as modules and call them?
Please can anyone give me a piece of code to combine the text from memo fields in 25 different queries and put it in one text box for printing? Thanks.
I have created menu bars for my access application and now would like to transfer many pieces of code in modules so that they can run using macros. I beleive this is the only way I can make run my code from the menu bar. Correct?
I am having problems with the modules since I have never used them and would like some help.
Here is a sample of code I now have on a push button in a form:
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("master")
stDocName = "MASTER"
stLinkCriteria = "[SSN]=" & "'" & Me![SSN] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Not IsNull(DLookup("[SSN]", "TEMPLATES", "[SSN] = '" & Me!SSN & "'")) Then Forms("EFORMS").Visible = False Else If IsNull(DLookup("[SSN]", "TEMPLATES", "[SSN] = '" & Me!SSN & "'")) Then DoCmd.OpenQuery ("Appendtemplates") End If End If
If Not IsNull(DLookup("[SSN]", "195", "[SSN] = '" & Me!SSN & "'")) Then Forms("EFORMS").Visible = False Else If IsNull(DLookup("[SSN]", "195", "[SSN] = '" & Me!SSN & "'")) Then DoCmd.OpenQuery ("Append195") End If End If
If Not IsNull(DLookup("[SSN]", "795", "[SSN] = '" & Me!SSN & "'")) Then Forms("EFORMS").Visible = False Else If IsNull(DLookup("[SSN]", "795", "[SSN] = '" & Me!SSN & "'")) Then DoCmd.OpenQuery ("Append795") End If End If
If Not IsNull(DLookup("[SSN]", "21", "[SSN] = '" & Me!SSN & "'")) Then Forms("EFORMS").Visible = False Else If IsNull(DLookup("[SSN]", "21", "[SSN] = '" & Me!SSN & "'")) Then DoCmd.OpenQuery ("Appendssa21tax")
End If End If Forms!eforms.lstPreInterview.Value = Null DoCmd.Close DoCmd.OpenForm ("Eforms") DoCmd.RunMacro ("CloseEforms") DoCmd.OpenForm ("Eforms")
End Sub
What I need is to add this code to a module, and make it run using a manu bar (I assume via macro). Thanks.
hello all i need a small thing to change in a module but am not too familiar with vb so i reached a dead end, here's the story:
i have a 'dog pedigree' database that i was working on, now there's a report where a dog's parents, their parents, and their parents need to be shown
that turned out to be out of my league so i paid a guy to do it for me, it worked except he didn't do exactly what's need and i can't get to him now :S
anyway, in the report page, you can notice that the name of each parent is shown, but i want the registration number of the parents to show as well, i tried modifying the module but it didn't work (am not a vb user), so can anyone help me add the reg number to the name of the parents?
also, in the report, the dog's color is appearing as a number instead of an actual color so if that can be fixed as well ...
to understand better: record 1 in dogs, click the preview diploma button you'll notice "tat" as dogname and "ry245" below that as registration number now sire is "pat" and dam is "titu", i want their registration numbers to show as well (and same for the rest of the parents)
i uploaded the file here for a closer look: http://www.designcrafts.org/dogs1.zip
Public Function fConList() Dim DB As DAO.Database Dim RS As DAO.Recordset
Dim strSQL As String Dim strText As String
strSQL = "SELECT Contact.To FROM Contact" ' Set DB = CurrentDb
'Open a Recordset and loop through it to fill the text box txtTest
Set RS = DB.OpenRecordset(strSQL, dbOpenForwardOnly)
How to put some other query given by name to instead of putting sql directly into string? I have also textfield that has this =fConList() as source. Is it possible that i will have some combo box or list of queries and one button. When i press this button the name of the query in the function will change to the chosen One from the list. Any Ideas? i'm beginner so, Thanks in Advance for some examples
I have created a query that includes a module that determine what the actual order date should be. This works correctly. Now, I want to take that date in another query to only show rows where RPODate exceed the recommended date.
I keep getting an error stating the query is to complex. If I run it without the >Checkdate in the criteriea for RPODate it's fine.
Any ideas?
Query 1 with module SELECT qryInstallationRPOrdered.ProjectID, qryInstallationRPOrdered.Phase, qryInstallationRPOrdered.Unit, qryInstallationRPOrdered.Tract, qryInstallationRPOrdered.Release, qryInstallationRPOrdered.DelDate, qryInstallationRPOrdered.InstallDate, qryInstallationRPOrdered.State, qryInstallationRPOrdered.RPODate, qryInstallationRPOrdered.NVDate AS CheckDate FROM qryInstallationRPOrdered WHERE (((qryInstallationRPOrdered.State)="NV"));
Query 2 SELECT qryInstallationRPONV.ProjectID, qryInstallationRPONV.Phase, qryInstallationRPONV.Unit, qryInstallationRPONV.Tract, qryInstallationRPONV.Release, qryInstallationRPONV.DelDate, qryInstallationRPONV.InstallDate, qryInstallationRPONV.State, qryInstallationRPONV.RPODate, qryInstallationRPONV.CheckDate FROM qryInstallationRPONV WHERE (((qryInstallationRPONV.CheckDate)>[RPODate]));