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..
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 have written a very simple query which get's it's criteria from a form I also created, which couldn't be any simpler itself. The form simply has a text box that I enter a value into, in this case, the date in a specific format "20041019". The query then pulls all records according to the form value. This query has always worked fine for weeks now. Today, suddenly it would not return any records. If I go into the SQL and manually enter "20041019" it will pull the appropriate records. It will NOT function when relying on the form value though. This has happened to me in the past, of course I did not document what I did to overcome the obstacle though. I have tried matchign the formats of the field in the table to the text box in the form so that they are both general numbers with 0 decimal places, originally they were both text format and it worked. I can't seem to figure out why this would happen. If anyone has any suggestions, I would GREATLY appreciate it.
I have a database with a table and 2 forms.One form (frmList) is a list of all records in the database, and the other form (frmInput) displays fields for a single record.There is a button in frmList which runs the following script. The user clicks a record in frmList, clicks the button, and the selected record opens in frmInput. ID is a text field containing digits and an alpha that is in both frmList and frmInput.
Code: Private Sub Command9_Click() Dim ID As String strCriteria = "ID = '" & Me.ID.Value & "'" DoCmd.OpenForm "frmInput", acNormal Form_frmInput.Recordset.FindFirst strCriteria End Sub
This script works as expected in Access 2010. However we recently upgraded to Access 2013 and since then, this script causes Access to crash ("Access has stopped working..." dialog appears).I have stepped through the script and the line causing the crash is
I can't find any problems with syntax or anything about Recordset.Findfirst being deprecated in 2013 so I suspected some kind of file corruption. To resolve this I have tried: Compacting and repairing the databaseDecompiling and recompiling the VBA modulesCreating a fresh database and copying all the objects into it
could this be due to a missing library or something? Are there other methods of resolving a corrupt database if that is the problem? Or as a last resort is there an alternative method to Recordset.FindFirst that I can use to open a form to a particular record while retaining the ability to navigate through other records?
I have a question about errors on null value.I have made a small database for tryout, it has to be implemented in another one.And the small database is working.I have one table where there is one field called BatchInput.I scan a barcode into it and let two query's breaking it apart. I scan this batch into the table field
BatchInput: 20 MAY 2004H149-082-79 A4147011A05
Then I have my first query (Qrybreak1) extracting the date and deleting H14
And query (QryResult) even wont start, giving a popup with Invalid procedure call..How could I handle Null on the part where there is no space after the partnumber (missing Certnumber)?
I'me running on Win7, Office 2010, Acc2003 format (.mdb), writing data to Excel 2010 (.xlsx)I have code to create an Excel file, send record set data to it, and then add some formulas and formatting. I was trying to tune up the formulas, when I got a pull back:Access VBA code suddenly stops running, and the file gets displayed in Excel
Code: 'ApXl is Application.Excel 'xlWSh is the Excel WorkSheet 'rst is my DAO.Recorset
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?
Hello, all! Can you please look at the following code and tell me why it throws a compile error of user type not defined. I'm trying to use this code to automatically pull in the previous room # and associated data into the next record, so that I don't have to enter the data every time, as sometimes there are fifty entries with the same room # and associated data. Can you tell me what it's wrong with it? Thank you!!
VB Code: Original - VB Code Private Sub Form_Current()Dim s As StringDim db As New ADODB.ConnectionDim rs As New ADODB.RecordsetSet db = CurrentProject.Connections = "SELECT Last(Room #) AS Room # FROM [tblFF&EBudget] WHERE Budget Line=(select max(Budget line) from [tblFF&EBudget])"Set rs = New ADODB.Recordsetrs.Open s, db, adOpenDynamic, adLockOptimistic'add to the tableWith rsMe![Room #] = .Fields("Room #")End WithSet rs = NothingSet db = NothingEnd Sub Private Sub Form_Current() Dim s As StringDim db As New ADODB.ConnectionDim rs As New ADODB.RecordsetSet db = CurrentProject.Connection s = "SELECT Last(Room #) AS Room # FROM [tblFF&EBudget] WHERE Budget Line=(select max(Budget line) from [tblFF&EBudget])" Set rs = New ADODB.Recordsetrs.Open s, db, adOpenDynamic, adLockOptimistic'add to the table With rsMe![Room #] = .Fields("Room #")End WithSet rs = NothingSet db = Nothing End Sub Thanks!
Maybe this should be posted under VBA.... not sure. Havent seen answer that works yet. Its a form with an option group "PickWO" When you pick an option, different fieilds become visible-non visible. I created a field "PickWOvalue" to store the option value "1" or "2". That part works fine.(visible) The problem is when you reopen the form to view the records the option box value does not show or change the fields visible properties. And the on open cuauses an error. Anyone see the problem?
Private Sub Form_Open(Cancel As Integer) Me.PickWOvalue.Value = Me.PickWO.Value End Sub ````````````````````````````````````` Private Sub PickWO_AfterUpdate()
Call NotVisible
Select Case Me.PickWO
Case Is = 1 Me.ReInspectionDate.Visible = True Me.Price.Visible = False Me.WOPreview.Visible = True Me.PrtWO.Visible = True Me.WBMInvoice_.Visible = False
Case Is = 2 Me.ReInspectionDate.Visible = False Me.Price.Visible = True Me.cmdPreTag.Visible = True Me.cmdPrtTag.Visible = True Me.WBMInvoice_.Visible = True
I have an access database that links to a SQL server. My problem is when I made a copy of the Access database, made changes to one sub report and mapped to test tables and now I have VB code that runs the overall report where the SQL gets jammed on the join, (which I noticed through debugging) but when I take the same SQL and run it in the Query view - the SQL works.
I have Header form and subform subform in it with following fields
Subform fields are :
1. MQE_No : (Text field as it will be like MG-120, MG230), Duplicate OK) 2. RPO_No : (Number field – Double, Duplicate OK ) The are project no. 3. ForemanNo (Number field – Long Int – Duplicate OK)
Header form fields are ;
1.ForemanNo – Long Int – No Duplicate 2.Other fields…
The subform field have ForemanNo One-To-many relationship with Header form.
Following project MG-411 need to enter (assign) to foreman no. 641
Actual data to store in subform
MG-411 (MQE_NO) 5421654 (RPO_NO) 641 (FOREMANNO)
I started to enter data into subform selecting the ForemanNo at header so records to enter in specific foremans account. Everything is fine here.
What I need is:
I would like to select / add another Foreman into the header and start entering same above data for another Foreman. Bcz sometimes we need to do like this in case previous Foreman may go on to a week vacation. We can not stop project for a week. So need to assign project to other foreman.
When selected the Project (MG-411) thru a combo to assign it with other foreman, it should give a short msg to user that this project has already been assigned to “XYZ” forman. Need to assign again “ (Y/N box )
If Y then data entered otherwise cancelled.
To achieve this, I did the following but only 50% success. (Used Cmbo CboRPO2 select MQE_NO). Tried to satisfy both condition but no use.
Private Sub CboRPO_AfterUpdate() If DCount("*", "T_RPO_Footer", "RPO_No = " & RPO_No) > 0 And DCount("*", "T_RPO_Footer", "ENO = " & ENO) Then MsgBox "RPO ALREADY ASSIGNED TO SOMEONE / FOREMAN", vbOKCancel, "WARNING!!!" Me.Undo Exit Sub Else
Dim Msg, STYLE, TITLE, HELP, CTXT, Response, MYSTRING If DCount("*", "T_RPO_Footer", "RPO_No = " & RPO_No) > 0 And DCount("*", "T_RPO_Footer", "ENO <> " & ENO) Then Msg = "RPO ALREADY EXIST WITH OTHERFOREMAN, ASSIGN AGAIN TO ANOTHER ?" STYLE = vbYesNo + vbInformation + vbDefaultButton2 TITLE = "!! ATTENTION !!" HELP = "TEST FILE" CTXT = 1000 Response = MsgBox(Msg, STYLE, TITLE, HELP, CTXT)
Else Me.MQE_NO = Me.CboRPO.Column(0) Me.RPO_No = Me.CboRPO.Column(1) Me.WORKSHEET_NO = Me.CboRPO.Column(2) Me.WORKORDER_NO = Me.CboRPO.Column(3) Me.WORK_DESC = Me.CboRPO.Column(4) Me.PL = Me.CboRPO.Column(5) Me.PipeLineKM = Me.CboRPO.Column(6) Me.DiaMeter = Me.CboRPO.Column(7) Me.PipeLength = Me.CboRPO.Column(8) Me.PipeLineArea = Me.CboRPO.Column(9) Me.P = Me.CboRPO.Column(10) Me.RPO_AMOUNT = Me.CboRPO.Column(12) Me.INV_AMOUNT = Me.CboRPO.Column(13) Me.Status = "WIP" Me.StatusID = 2 Me.CboStatus.SetFocus End If End If End Sub
I tried with following code also
'Dim cdn As String 'cdn = "[MQE_NO] = '" & Nz(CboRPO, "") & "'" 'cdn = cdn & " And ENO = " & ENO
'If DCount("*", "T_RPO_Footer", cdn) > 0 Then 'MsgBox "THIS RPO ALREADY ASSIGNED TO THIS FOREMAN", vbOKOnly, "WARNING!!!" 'Me.Undo 'Exit Sub 'Else ‘do something ‘End if
Hi all I have another code Problem, Can someone help me with this. I have two fields One called cust_birthday ( date field ) And one called cust_age ( text field ) The code below I put in a module name age function.
The Problem, is I get no return from this code.
What is wrong with this code ????
Option Compare Database
Public Function Age(cust_birthday As Date, Optional cust_age As Variant) As Integer Dim dteBase As Date, intCurrent As Date, intEstAge As Integer If IsMissing(SpecDate) Then dteBase = Date Else dteBase = SpecDate End If cust_age = DateDiff("yyyy", dteDOB, dteBase) cust_age = DateSerial(Year(dteBase), Month(dteDOB), Day(dteDOB)) Age = cust_birthday + (dteBase < cust_age) End Function
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.
I have an issue with a code that I have in a form which adds rows in a table as many times as categories chosen from a list. However, the code is not working correctly: it adds the information and creates a row with a category in blank, in addition to the rest of the rows with one of the chosen categories. I would like for this not to happen, to add only as many rows as the categories chosen.
My code is the following:
Private Sub cmdUpdate_Click() Dim valSelect As Variant, MyDB As DAO.Database, MyRS As DAO.Recordset Set MyDB = CurrentDb() Set MyRS = MyDB.OpenRecordset("Tasks", dbOpenDynaset) MyRS.MoveFirst
This has been annoying me to now end. I have a master form with 3 text boxes, and 3 subforms with about 26 more text boxes.
How can I make the tab stops flow from one subform to another? It's like the tab stops won't get "linked up" by virtue of them being on the same master form.
What I want to do instead is open an existing .XLSM wokrbook delete or update the 7 sheets it creates and replace them with the new query results from access.
I love this code below because it works really well but now I have a new requirement. I have a workbook that has a "dashboard" sheet that looks at the sheets from acccess and summerizes the data. So, I'd like Access to open that "template" excel workbook and delete the old sheets and put in the new ones..The required sheets to keep are called "Metrics", "Validation" and "Mara"
What I was trying to do for the past few hours was another work around which was to have Access run this code, then excel run some code to import the "dashboard" formulas but I can't get it to copy to another workbook because it links to the OLD workbook..Here is the working code that needs modding:
Code:
Option Compare Database Public Function ExportAdvanced() Dim strWorksheet As String Dim strWorkSheetPath As String Dim appExcel As Excel.Application Dim sht As Excel.Worksheet Dim wkb As Excel.Workbook Dim Rng As Excel.Range Dim strTable As String Dim strRange As String Dim strSaveName As String Dim strPrompt As String Dim strTitle As String Dim strDefault As String
I'm trying to concatenate several fields from a set of tables/subtables. But for some reason, it concatenates the first 3 records, then stops. I should clarify that the concatenation "skips" a subtable. Here's the structure of the relationships (not sure if this pic is working so I'm adding the link to the screen shot)
[URL] ....
and the concatenation itself
As you can see, I'm looking to create a concatenation of (Vendor_Code)&(Vendor_Item_Code)&(Item_ID) which runs through the subtable Items_Child, but doesn't use any field in Items_Child
I'm using a combo box to pull data from a table to auto populate the fields on my form. But for some reason, it stops inserting the data after city (column(6) and I can't figure out what's going on. When I run the query the data is there, if I change the order of the columns, the data shows. Here's the code:
I'm using an Access 2010 report to recreate a spreadsheet that contains rows consisting of fourteen columns of data. Each column is totaled. The data types are numeric and the property sheet format is either Standard or Percent depdening on the column.
In order to track the totals, I utilize two text boxes for each column. One is visible and contains the data for that particular row. The other is hidden and has its Running Sum property set to "Over All". The final totals row consists of text boxes that reference the final result of the running sum text box.
This works up to a point. I see correct totals results for columns 1-10. Then for some reason the running count appears to stop for the second to last row of column 11. (It's always the second to last row). As a result, the totals for this column (11) and subsequent columns (12-14) do not total.
I have witten a code in the close event of a "Primary" form that would update a Combo boxe on a "secondary" form only if the "secondary" form is open. ie:
Private Sub Form_Close() If Forms!frmEnquiry.Open Then Forms!frmEnquiry!CboCustomer.Requery Else DoCmd.Close End If End Sub
This code keeps giving me an error, is anybody has got any idea why? Thanks in advance.
I have an asset data base to generate individual asset detail reports with a sub report on the same page listing similar assets from a separate query. I have set the master and child fields, one to many. This works perfectly for the first two assets (pages), however the sub report stops showing data on the third asset (page).
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 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.
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?