Modules & VBA :: Creating Msg Box That Runs A Code

May 29, 2014

I have a little problem in creating a msg box that then activate a code. How can I do? I was doing

Private Sub Chiusura_Pratica_Click()
MsgBox "Bla Bla Bla " _
VbMsgBoxStyle.vbYesNo
If Response = vbYes Then
Me.Stato.Value = "A Scadere"
Me.Assegnato_a.Value = ""
Else
MyString = "No"
End If
End Sub

But it doesn't work...

View Replies


ADVERTISEMENT

Modules & VBA :: Code Runs OK Once But Error Next Time

Jun 26, 2015

The task is (1) output an Access query to Excel (2) overwrite that file if it already exists (3) apply specific formatting to the header row and the other rows in Excel. I have cobbled the code together from two sources. The beginning and end are adapted from code on btabdevelopment.com but the large insert in the middle is code I got form a project a former colleague had done. But he's no longer around.

The problem: I click the button and everything works OK. The file is created and formatted just how I want. If I click the button a second time though, it seems to run OK, but when I open the file it is NOT formatted. However, theres another window behind it called Book 1 which has all the data and all the correct formatting it just hasnt been saved. If I click it a third time I get an error message that says Object variable or With block variable not set. Im not even 100% all that is accurate because I have tried it a multitude of ways, closing and re-opening the form, closing and re-opening Access itself, starting with Excel open or closed, never with the destination excel file open though. I dont seem to get exactly the same behaviour any two times. But as far as I can see, if I close and re-open Access, it always works the first time. So I can live with it.

Code:
Private Sub cmdExport_Click()
On Error GoTo Errhandler
Dim rs As DAO.Recordset
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

[code]....

View 8 Replies View Related

Refresh After Code Runs On Activate Or On Load

Jul 21, 2015

Access 2007, Sql Server 2008 R2. Problem with refresh.

Form 1, (Single Form) Parent Form, contains Property Year Detail data. PK = PropYrDetID. This is a SINGLE FORM

Form 2, (Single Form) Child form, contains land square footage data from multiple records. PK = SPYDID FK = PropYrDetID. This is a SINGLE FORM.

The code below executes every time Form 1 opens, activates or whatever. The reason is that data in Form 2 changes frequently. Thus every time Form 1 opens the end user will see the latest data.

"Form 1" receives a series of values that it obtains from VBA code that runs when it opens or activates.

"Form 2" has the data being summarized in Form 1.

All of the code and queries below run fine and return the correct values from Form 2 to Form 1. My problem is Refresh on Form 1.

I've tried the code in the On Current, On Activate, On Load of Form 1. Mostly the data shows up in Form 1. Other times parts of the data are left out. I have to hit F5 or close and reopen the form, and then the data appears. When I don't see data on Form 1, I check the underlying table and the correct data exists. I don't know how to achieve a 100% refresh success. I have tried me.refresh and different Events all over the place.

All of the code below runs when Form 1 opens. Queries are fine, Equations are fine, Tests run fine. It's the results showing up that I am having the problem with.

I don't think the issue is with the code but with the Refresh. Here it is for your review.

The term "Equations" is the customers. There are 5 equations. Some have a series of tests after the Equation to determine the result.

Code:

Private Sub Form_Activate()
Dim rs As Variant
Dim varAOProp As Variant
Dim varAOIni As Variant
Dim varAOCert As Variant
Dim varBORIni As Variant
Dim varBORFinal As Variant

[Code] ....

View 5 Replies View Related

Forms :: Label On Form Will Not Update As The Code Runs In The Background

Mar 17, 2014

I have a userform that pops up when I am implementing a VBA subroutine. The nature of the form is simply to update the user what progress through the operation the code is using a label called lblProgressText.

So, I have a form called frmProgress and in my loop I use:

Code:
DoEvents
Form_frmProgress.lblProgressText.Caption = Format(rsLongItems.PercentPosition / 100, "0.00%") & " - Long items"
Form_frmProgress.pbProgressBar = rsLongItems.PercentPosition
Form_frmProgress.Requery
Form_frmProgress.Refresh
Form_frmProgress.Repaint

I know I don't need the .requery, .repaint and .refresh lines but I put in there just to check it wasn't that causing the issue.

When my code runs, the form is opened using:

Code:
Form_frmProgress.Modal = False
DoCmd.OpenForm Form_frmProgress.Name, acNormal, , , , acWindowNormal

The form Popup property is set to Yes.

The lblProgressText control just wont update (but earlier today it was so maybe I have broken something).Btw, all this code is run from a Module, not in the form object.

View 3 Replies View Related

Modules & VBA :: Creating A Small Loop To Run Code

Oct 1, 2013

creating a small loop to run code.For each record from AREA with PLANTPROGRAMID = VARIABLE Then...In this example, my table is called Area, my field is called plantprogramid, and my variable is defined earlier in code.

View 5 Replies View Related

Modules & VBA :: Create Single Master Control Program That Runs Each Individual Application

Dec 23, 2014

I have a series of 7 separate Access 2010 programs that are designed to run under the control of a scheduler, and they must always finish. Errors are trapped and logged but mustn't stop the processes completing.

What I'm trying to do now is to create a single master control program that runs each individual application, one after the other, in order. And each individual app cannot start until the previous one is finished.how to call a separate Access program and know when it has finished.

View 2 Replies View Related

Difficulty Creating Code

Apr 8, 2007

I am having difficulty creating code that will compare a date in one table (or query) in the [Expire] field and subtracting two months from the date and automatically placing the newly calculated date into the table (or query) in the [Notify Expiration] second field. For example:

Expire Notify Expiration

01/01/2007 11/01/2006
02/01/2007 12/01/2006
03/01/2007 01/01/2007
04/01/2007 02/01/2007
05/01/2007 03/01/2007
06/01/2007 04/01/2007
07/01/2007 05/01/2007
08/01/2007 06/01/2007
09/01/2007 07/01 2007
10/01/2007 08/01/2007
11/01/2007 09/01/2007
12/01/2007 10/01/2007

Please note that for the month of January and February, the subtraction is minus two for these two months and the subtraction is minus one for the year. All other subsequent months just subtracts two for the months leaving the year intact.
I would appreciate any help that will progmatically accomplish these calculations.

Thanks

Charles Moery
Keypounder2@aol.com

View 4 Replies View Related

Creating An Index Using Code? Any Other Way Besides On The Table?

Feb 17, 2005

I am pullling data from a query using an unbound form and a query that that uses linked tables. I can not edit the index of the tables, so is there a way i can create a new index for sorting data in a form?

View 2 Replies View Related

Creating 'flashing' Form Controls - Problem With Code

Jul 14, 2006

Hello everybody,
Could anyone out there please help me with a small coding problem that I am experiencing....

I have a calculated control on my startup form called txtCurrentAge on which I have put VB code in the on-timer event of the form which makes the control 'flash on & off' if the persons age is below 18.
code as follows:


Private Sub Form_Timer()
If Me.txtCurrentAge.Value < 18 Then
Me.txtCurrentAge.Visible = Not Me.txtCurrentAge.Visible
Else
Me.txtCurrentAge.Visible = True
End If

End Sub

Everything works fine but when a user inadverently clicked on the control by mistake it caused the following error to be displayed: Runtime error 2165 "you cant hide the control that has the focus". What does this mean and how best could I prevent this from happening again as I cant guarantee that any of my users wont click on it again?? The text box concerned has been made 'visible', has not been 'locked' and is 'enabled'.
'
I find this 'flashing action' to be very useful and would like to keep it on my form....

I have searched on this site and various others but have been unsuccesful....

Any help or guidance would be very much appreciated.
P.S I obtained this code via databasedev.co.uk and adapted it to suit my particular DB.

Best Regards

CarolW

View 4 Replies View Related

Query Runs All Day

Feb 28, 2007

Dear pro,
I am having difficulties running a simple query that it runs all day and I have to kill it at the end of my date because it does not finish. Here is the statement that I would like some suggestions on how to improve it for faster results:
SELECT code, acct nbr, date, user, sum(amt)
FROM Tbl a
WHERE code IN
('AB',
'BC',
'CD',
'AA',
'BB',
'CC',
'ZZ'
)
AND date BETWEEN TO_DATE ('20070101', 'YYYYMMDD')
AND TO_DATE ('20070131', 'YYYYMMDD')
group by code,acc nbr,date,user

thank you...in advance for all your help..

Wilman.

View 1 Replies View Related

DB Runs Slow Over Network

Sep 18, 2006

I have a 16Mb DB. The intention is for users to access this over the network without copying onto their local machines.

At present, many of the forms are located on 1 master form and they are all subforms on tabs. There are a lot of calculated control boxes on the forms, and these seem to be very slow to bring back the data over the network whereas on my local machine, the data is displayed in a couple of seconds.

COuld this be sped up somehow? Maybe using queries or other methods?

View 12 Replies View Related

Query Runs Slowly

Aug 8, 2006

I have a table with a rotating work order number (from 1 to 9999 then starts over) and because there may be more than one record with the same work order number I need to find the most recent one. Here's the query I'm using the find the most recent record for each work order number:
SELECT * FROM [Work Orders] AS wk1
WHERE NOT EXISTS(
SELECT * FROM [Work Orders] AS wk2
WHERE wk1.[Work Order #] = wk2.[Work Order #] AND
wk1.[Call In Date] < wk2.[Call In Date]
);

Right now the table has a litttle over 10000 records and it takes anywhere from 10 seconds to 60 seconds to return the results. Is there a way I could possibly speed up this query?

View 2 Replies View Related

Hide Toolbar When Program Runs

Jul 20, 2006

I have create my first program. When you click on the program it runs (I am an expert now!) But when I want it to run, I want it to hide the toolbars on the top so no one can alter it. Any suggestion?

View 1 Replies View Related

Printing Report Re-runs All Queries

Jan 31, 2008

I have a report with several subreports which run agains a very large table. If I decide to print the report after examining it, all of the underlying queries must run again. Is there any way around this to avoid this delay, other than exporting as rtf or snp?

Thanks,

Randy

View 1 Replies View Related

Multi Combo Boxes, Which One Runs

Oct 20, 2005

I have 6 combo boxes on a form, which call a report based on a query. The idea is that the user can query data 6 different way. How do I/ or the user know which one is actually running first. Would the order left to right make a difference? (None have sort ascending or descending)

View 1 Replies View Related

Calculate Number Of Animals & Runs

May 4, 2006

I own a kennel and was wondering if there is a way to put in 2 different dates and get totals of animals during that time and totals of kennel runs?
Thanks.

Sorry, my reservation table includes Kind, New (y/n), Owner's Name, Pet's Name, Date In, Date out, Price, # of Units needed, and # of dogs. I need to put in dates ie: 5-10-06 to 5-25-06 and get a total of dogs and a total of units so we don't overbook. When I made this program I have little idea of how to do it and now years later I'm trying to tweak it. Thanks again

View 14 Replies View Related

A2003 Query Runs Under XP, Not Vista

Feb 26, 2008

I apologize up front for how long this is, but the queries involved are a bit complex.

I developed a database in Access 2003 running on XP sp2 to score events for our dog club. Everything works. I recently had to migrate to Vista. I installed Access without a problem. No changes to the database were made. Almost everything works except for a few queries. I continually get the error "Object invalid or no longer set." This is not running on a network - it is local on the hard drive. Setting XP compatibility mode and runing as administrator do not help.

The query that is actually causing the problem is the third in a chain, meaning it queries a dataset produced by another query, which in turn queries a dataset produced by a third query. This all works under XP.

I have narrowed the problem down to the ORDER BY statement in the query (I prefer to work in SQL). If I remove one of the sort criteria, everything works, except the results are displayed in the wrong order. It does not matter if I click the "run query" button on my form, or simply execute the query from the list of queries, the same error occurs. This is where I'm stuck.

Here is the chain. This query pulls data out of multiple tables and performs some point total calculations. This one is rather complex, but works fine. It produces a blob dataset of all entries for all events and sets points for each entry.

SELECT tblResults.Event_ID, tblEvents.Event_Name, tblClass.Class, tblDogs.Dog_Name, tblDogs.ID, tblDogs.Owner, tblDogs.Sex, tblResults.Dog_Wt, tblResults.Cert, tblResults.Ex, tblResults.Cplt_Wt, tblResults.Time, tblResults.Final_Wt, tblResults.Dist, tblResults.Place, IIf(tblResults!Cplt_Wt<400,0,5) AS Bonus, IIf([Bonus]=0,0,IIf(tblClass!Class="D",(tblEvents!D_Count-(tblResults!Place-1)+[Bonus]),IIf(tblClass!Class="C",(tblEvents!C_Count-(tblResults!Place-1)+[Bonus]),IIf(tblClass!Class="B",(tblEvents!B_Count-(tblResults!Place-1)+[Bonus]),IIf(tblClass!Class="A",(tblEvents!A_Count-(tblResults!Place-1)+[Bonus]),(tblEvents!O_Count-(tblResults!Place-1)+[Bonus])))))) AS Points, Round(tblResults!Cplt_Wt/tblResults!Dog_Wt,2) AS xbdywt
FROM tblClass INNER JOIN (tblEvents INNER JOIN (tblDogs INNER JOIN tblResults ON tblDogs.ID=tblResults.Dog_ID) ON tblEvents.Event_ID=tblResults.Event_ID) ON tblClass.Weight=tblResults.Dog_Wt;


That resulting dataset feeds the next query, which also works fine. This one sums the points for each entrant by class for the season, only selecting entrants that have been in 3 or more events.

SELECT DISTINCTROW qryAll_Results.Class, qryAll_Results.Dog_Name, qryAll_Results.Owner, Sum(qryAll_Results.Points) AS Points
FROM qryAll_Results INNER JOIN qryPulls_Entered ON qryAll_Results.ID=qryPulls_Entered.ID
WHERE qryPulls_Entered.CountOfID>3
GROUP BY qryAll_Results.Class, qryAll_Results.Dog_Name, qryAll_Results.Owner, qryAll_Results.ID;


This last query is the one causing the headache. This one pulls the 10 entrants with the most points for a class, sorts them by points, then assigns 1st-10th place.

SELECT TOP 10 qryOverall_Totals_All_Classes.Dog_Name, qryOverall_Totals_All_Classes.Owner, qryOverall_Totals_All_Classes.Points, ((SELECT COUNT(*) FROM qryOverall_Totals_All_Classes AS T WHERE T.Class = "A" AND T.Points > qryOverall_Totals_All_Classes.Points)+1) AS Place
FROM qryOverall_Totals_All_Classes
WHERE (((qryOverall_Totals_All_Classes.Class)="A"))
ORDER BY qryOverall_Totals_All_Classes.Class, qryOverall_Totals_All_Classes.Points DESC;

If you remove 'qryOverall_Totals_All_Classes.Points DESC' from the ORDER BY statement, the query runs. If you leave it in, it generates the error "Object invalid or no longer set". I've tried using the alias, but that didn't work either.

Any thoughts? I can post the database somewhere if someone needs to see the whole thing.

View 5 Replies View Related

Forms :: Create A Form That Runs Only Once When Db First Run For Name?

May 27, 2013

is it possible to create a form that runs only once when db first run for name etc. And then once saved cannot be changed by end user.

The last bit I can do its just the making it run once as a popup.

View 13 Replies View Related

Need To Close An Open File Before A Macro Runs.

Nov 28, 2007

I need to find a way to close a file (spreadsheet) if it was left open by a user before my scheduled macros need to delete and remake that file to update it. Is there a way to do this in Access? I've been looking for scripts everywhere... Any help is greatly appreciated. Thanks, Rick.

View 1 Replies View Related

Update Query No Longer Runs As Transaction.

Feb 22, 2008

Hi,
I have been using the following query, literally for years, without any changes. I run it from code using db.execute, and I do use the dbfailonerror option.

UPDATE TST3 SET [date] = Mid([timedate],8,2) & '/' & Mid([timedate],10,2) & '/' & Right([timedate],4), [time] = Left([timedate],2) & ':' & Mid([timedate],3,2) & ':' & Mid([timedate],5,2), Serial = [serial] & '3';

One of the things it does is to add a '3' to the end of the [serial]. [serial] is the primary key in the TST3 table. You might think that there would be a problem if, say, I have a list of serials containing
35
56
1
13
and I'm trying to update them to
353
563
13
133
But this has worked OK in the past. NOW I'm getting a KV Error when it tries to update the 1 to 13, because there's already a 13 in the table.

Even stranger, when the query fails, all the rows BEFORE the offending record DO get updated. So the query fails, and I end up with:
353
563
1
13
(and yes, I DO have dbfailonerror set)

So, it looks to me as if update queries are no longer running as transactions.
I am pretty certain that action queries have always been run transaction-wise in the past... if the query fails, the whole thing should fail. WHY is the transaction processing no longer working for this update query? Has anyone else noticed this?

I recently ran microsoft update and am now running
Access 2002 (10.6771.6830) SP3.

View 7 Replies View Related

User Inputs Table When Query Runs.

Mar 14, 2008

I have a database with 96 tables.
8 tables per month
one query pulls the desired information.

My question is this, currently the query looks to all the January Tables.

Can I configure one query to request user input(month) and then the query looks to the tables based on the users input(month).

View 4 Replies View Related

Change Mouse To EggTimer While Module Runs

Dec 13, 2004

I've a module which outputs some information to an Excel spreadsheet. This can take about 10 seconds. How can I change the mouse pointer to the egg timer whilst this runs? I have Excel visible set to false, until the end? I know this can be done in a macro.

View 1 Replies View Related

Forms :: OnLoad Runs When Closing Form

Oct 9, 2013

I have an A2007 application running on XP. From main form, Form1, another form, Form2, is opened.

When I attempt to close the application by clicking in the cross in the rh-corner of Access window, I get a crash midway through the OnLoad of Form2. I cannot figure out why the heck the On Load event fires when the form is being closed, and have some difficulties stepping through the code.

I recall having heard of OnLoad firing when trying to close a Form.

View 6 Replies View Related

MS Access Runs Slowly For Client PC's After A Update Or Insert.

Jan 29, 2007

Hi,

We are using MS Access as the backend to our application which has been written in delphi and have run into a problem that we have not been able to solve. Hoping someone has run into this before or any suggestions are much appreciated.

The problem:

MS Access runs slowly for client PC's after a update or insert.

- I am using ADO to connect to the Access database, which is using the OLEDB for ODBC Provider.
- The application I have sends queries (both select and update) direct to the database (ie client datasets are used).
- When only select queries are sent to the DB the response time is fine.
- When an update or insert query is sent to the DB the response time of the PC it is run on is fine.
- When an update or insert query is sent to the DB the response time of any other client PCs running the application take about 5 to 6 times longer to run queries than before the updateinsert query was done. This is the issue that I am having.
- Any client PC's that display this slower response time, can have their response time returned to normal by closing down the application and restarting it.
- No more than 3 PC's connected at one time to the DB.
- Maximum database size of 150MB.
- Problem occurs on various network setups, including domain and workgroup.
- Problem only surfaces for users at times well after any application updates have been applied (ie several weeks after, and then once the problem starts it continues).
- It does not occur for all user sites.

I have tried and thoroughly tested the following to no avail...
- Applied all the latest microsoft updates
- Closing and re-opening the ADO connection after updatesinserts
- Changed the ADO provider to Jet 4
- Saving the DB in Access 2000 or 2002 format
- Set the Default record locking to 'No Locks' and 'All records' and 'Edited record'
- Used 'Open databases using record-level locking' selected and unselected
- Many application techniques (using delphi) to work around the issue. Many of which have indeed improved general response times, but have not resolved this particular issue.

The only thing I have tried that has resolved the issue is... - Upsizing the database to SQL Server (Unfortunately this option is not a viable one for us at this stage, so I need to find a resolution to it while still using the Access DB).

Thanks for your help

View 1 Replies View Related

Append Query Adding All Records Evertime It Runs

Aug 8, 2005

I have an append query that everytime it runs it will simply duplicate the records. ex.. sample table has 11 records if you run it again the tableB will now have 22 records. I need it to only update the records, so if someone makes in change / new record in tableA it will only update the records in TableB.
I have the Primary Key set to Yes no duplicates.
TableA Primary Key is ID
TableB Primary Key is CustomerID

Thank you,

Chuck

View 3 Replies View Related

Query Runs When A Policy Number Is Input In A Form

Jan 26, 2007

I have a form set up and would like to have field update to a table when a policy number is input into the form. The fields are extracted from a linked table and are not viewed on the form but need to be written to a table to create a report. I'm confused on the sets to take to handle this. I think i need to use the "onchange" property and set up a macro that runs a query but how does the query write to the table?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved