Quantcast
Channel: Access for Developers forum
Viewing all 14673 articles
Browse latest View live

VBA and BigInt Access Data Type

$
0
0

Access 2016 in its last release add the bigint data type, Ok!...

but...

I do not find a relative variable type so it is not so much useful... 

how can i manipulate this data type in vba? i must consider it as a string?

many thanks!


Recurring corrupted database

$
0
0

On a regular basis an Access 2013 gets corrupted and Compact and Repair fixes the problem.

Is there a way to investigate the reasons that are causing the corruption? 


Comparing two date records that could be blank

$
0
0

I am trying to write a function that will take two dates, check if either one is blank, return the difference if both dates have values or return nothing or a static number if either record is blank.  Below is the code I am trying to use but I get data type mismatch in criteria expression error.

Public Function DayComparison(StartDate As Date, EndDate As Date) As Integer

If IsNull(StartDate) = False Then
    If IsNull(EndDate) = False Then
        DayComparison = WorkingDays(StartDate, EndDate)
    Else
    DayComparison = -100
    End If
Else
DayComparison = -100
End If
        
Exit Function
End Function

For reference, the WorkingDays function is below.

Public Function WorkingDays(StartDate, EndDate) As Integer
On Error GoTo Err_WorkingDays
Dim intCount As Integer
StartDate = StartDate + 1
intCount = 0
Do While StartDate <= EndDate
Select Case Weekday(StartDate)
Case Is = 1, 7
intCount = intCount
Case Is = 2, 3, 4, 5, 6
intCount = intCount + 1
End Select
StartDate = StartDate + 1
Loop
WorkingDays = intCount

Exit_WorkingDays:
Exit Function

Err_WorkingDays:
Select Case Err

Case Else
MsgBox Err.Description
Resume Exit_WorkingDays
End Select

End Function

USB Cash Drawer Trigger DT-100U

Access 2013 drops support for adp projects. What alternatives do you suggest?

$
0
0

My main application (Screenshot of a typically complex form attached):

MS Access 2003-2010 adp Project containing 100+ forms including modal dialogs and main forms with header, footer and up to 3 subforms, each looking at their own linked data, 64 reports/subreports and 34 modules including MS Office and Windows API integrations. 

This looks at an SQL 2005-2012 database with 52 Tables, 64 views, 44 stored procs and 38 functions

So what are the viable alternatives to Access 2010 .ADP -> SQL Server 2012?

Requirements:

Rich forms/subforms environment with vb method coding, event handling, report generation, binding to fully relational SQL database with table, view and stored proc objects:

  • Microsoft Lightswitch (Desktop or Web App)

Quick and lean but probably too limited for serious development

  • Sharepoint Designer Lists etc using BDC

Simple for single table interaction, don’t know what potential

  • Sharepoint Visual Web Parts via Visual Studio

Little support for RAD or database bound controls

  • Access 2013 accb with SQL Server linked tables

Path of least resistance. Don’t imagine this supports stored procs etc

  • Access 2013 Sharepoint Web App

MS vision for the future Don’t know much about this yet. Requires specific client environment restricting market but may be the way others want to go.

  • Visual Studio Web App/Windows Forms with only .net Data Controls

Cheap option but hard work. Complex forms with data linked controls are tedious to develop without 3<sup>rd</sup> party tools. No bundled reporting option eg Crystal

  • Visual Studio Web App/Windows Forms with 3rd Party dev tools:

Much easier development but can be expensive and may result in continuing commitment and high dependency on the future/support of the 3rd party. Which of these tools to consider?

What would you do? Or are you already on this road. How are you finding it?

Grateful for any suggestions!

Stephen Solt 

Construction industry database developer

Planchest ltd

Warmington PETERBOROUGH UK

How do I catch the Label content - the label caption?

$
0
0

Hi

I want to catch the content - label caption on a Form and the use it as Subject in an email.

I know the email part, but cant catch the content/caption.

The name of the Label is "Title"

Tried Me.[Title] and Me![Title]


Cheers // Peter Forss Stockholm

Query to aggregate a certain column

$
0
0

HI Folks -

I have a table in my database that is populated as such:


Local Cost CenterHC CategoryFISCAL YEARPERIOD
JP000019200000120185
JP000019200000120185
JP000076090000820185
JP000076110000120185
JP000076110000120185
JP000076120000120185


However, I need a query to be able to Aggregate the [Local Cost Center Column] for each [HC Category] and place a total column as [Total].

The end results should look like this:

Local Cost CenterHC CategoryFISCAL YEARPERIODNumber of Headcount
JP0000192000001201852
JP0000760900008201851
JP0000761100001201852
JP0000761200001201851

In my efforts, I came up with this query and seems to be working OKAY, but is this even correct?

SELECT 
	  MIN([Global_Monthly_Headcount].[Scenario]) AS [Scenario]
	, [Global_Monthly_Headcount].[Cost Center - Long Name]
	, MIN([Global_Monthly_Headcount].[Finance Headcount Grouping]) AS [Finance Headcount Grouping]
	, MIN([Global_Monthly_Headcount].[Fiscal Year]) AS [Fiscal Year]
	, MIN([Global_Monthly_Headcount].[Period]) AS [Period]
	, COUNT([Global_Monthly_Headcount].[Cost Center - Long Name]) AS [Total Headcount]
FROM [Global_Monthly_Headcount]
WHERE 
	[Global_Monthly_Headcount].[Company] LIKE '*US34*' AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 1
	OR [Global_Monthly_Headcount].[Company] LIKE '*US34*' AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 3
	OR [Global_Monthly_Headcount].[Company] LIKE '*US34*' AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 8
GROUP by [Global_Monthly_Headcount].[Cost Center - Long Name], [Global_Monthly_Headcount].[Finance Headcount Grouping]

Thanks!

Loss of embedded macros in ACCESS 2013

$
0
0

I have seen one reference to this from 2012, but there was no real solution given.

One of my users pointed out that when clicking a button, nothing happened. When I looked at it, I saw that the embedded macro that used to open aother form, was gone. The latest application release did not involve changes to either the calling or called forms.

The post from 2012 mentioned that he had compiled the code, and that is when the problem occured. I cannot verify this in my case. I do compile the code, and create an .accde executable. Perhaps that is when the problem occurs. Wherever the problem is, it is a problem. Every time I make a change anywhere in the app, I don't want to have to waste my time going through every form and report to make sure that something else has not disappeared.

It is totally random, so I cannot reproduce it, although I have tried.

Build(?) 15.0.5045.1000

 Any help would be appreciated.

 Thank you

John Crawford


Manual Macro versus button macro - errors??

$
0
0

Hello, 

I have a Macro that Runs correctly when I double-click it directly in Macros section, but won't when assign that same macro to a Button on a form, I get an error about "the command or action 'gotorecord' isn't available now".  I read somewhere about the "Focus" of the macro being wrong, but I don't know how to fix it.  And why does the macro work correctly when I double-click it directly? 

I've also tried your suggestion "add it directly from the button's On Click event property, without even creating a separate VBA event procedure, by placing an expression like this on the On Click property line of the property sheet:  =YourFunctionName()."  When I do that, and click the button, I get a different error "Application-defined or object-defined error".

Can someone please help.

-Thanks, Ron M.

How to calculate median in report footer?

$
0
0

I have a report that generates from a query in Microsoft Access. Each record that is pulled into this report has a number value for the field CallRcvd to Arrival.

I am trying to calculate and display in the report footer the median of CallRcvd to Arrival on only the records that are pulled into this report. How can I go about this ?


Trouble UNIONing queries together - where am I going work?

$
0
0

HI Folks -

Both of these queries run correctly seperately, but having trouble with the UNION.

SELECT 
	  MIN([Global_Monthly_Headcount].[Scenario]) AS [Scenario]
	, [Global_Monthly_Headcount].[Cost Center - Long Name]
	, MIN([Global_Monthly_Headcount].[Finance Headcount Grouping]) AS [Finance Headcount Grouping]
	, MIN([Global_Monthly_Headcount].[Fiscal Year]) AS [Fiscal Year]
	, MIN([Global_Monthly_Headcount].[Period]) AS [Period]
	, COUNT([Global_Monthly_Headcount].[Cost Center - Long Name]) AS [Total Headcount]
FROM [Global_Monthly_Headcount]
WHERE
	[Global_Monthly_Headcount].[Company - ID] LIKE '*SG31*' 
		AND [Global_Monthly_Headcount].[CMSO?] = 'TRUE' AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 1
	OR [Global_Monthly_Headcount].[Company - ID] LIKE '*SG31*' 
		AND [Global_Monthly_Headcount].[CMSO?] = 'TRUE' AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 3
	OR [Global_Monthly_Headcount].[Company - ID] LIKE '*SG31*' 
		AND [Global_Monthly_Headcount].[CMSO?] = 'TRUE' AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 8
GROUP BY [Global_Monthly_Headcount].[Cost Center - Long Name], [Global_Monthly_Headcount].[Finance Headcount Grouping]

UNION SELECT 
	  MIN([Global_Monthly_Headcount].[Scenario]) AS [Scenario]
	, [Global_Monthly_Headcount].[Cost Center - Long Name]
	, MIN([Global_Monthly_Headcount].[Finance Headcount Grouping]) AS [Finance Headcount Grouping]
	, MIN([Global_Monthly_Headcount].[Fiscal Year]) AS [Fiscal Year]
	, MIN([Global_Monthly_Headcount].[Period]) AS [Period]
	, COUNT([Global_Monthly_Headcount].[Cost Center - Long Name]) AS [Total Headcount]
FROM [Global_Monthly_Headcount]
WHERE
	[Global_Monthly_Headcount].[Company - ID] LIKE '*SG31*' 
		AND [Global_Monthly_Headcount].[CMSO?] IS NULL AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 1
	OR [Global_Monthly_Headcount].[Company - ID] LIKE '*SG31*' 
		AND [Global_Monthly_Headcount].[CMSO?] IS NULL AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 3
	OR [Global_Monthly_Headcount].[Company - ID] LIKE '*SG31*' 
		AND [Global_Monthly_Headcount].[CMSO?] IS NULL AND [Global_Monthly_Headcount].[Finance Headcount Grouping] = 8
GROUP BY [Global_Monthly_Headcount].[Cost Center - Long Name], [Global_Monthly_Headcount].[Finance Headcount Grouping]

Where am I going wrong? Thanks!

Mail body differs

$
0
0

Hi all,


One of those bugs I do not see:

I have a database that needs to renew the license every year. The code to send the e-mail as follows:

    DoCmd.SendObject , , , , , , "New Software License", "Your new Software license is: " _& vbCrLf _& Text7 _& vbCrLf _& vbCrLf _& "Please copy the above license code and activate the new license as follows: " _& vbCrLf _& "1. Log into the database " _& vbCrLf _& "2. Under the Administrator Tab, click on the Activate License option " _& vbCrLf _& "3. Paste the new license number in the License Number field " _& vbCrLf _& "4. Click on Save " _& vbCrLf _& "5. Click on Activate " _& vbCrLf _& "6. Close the form if it did not close automatically.", True

All works fine. When the mail opens where I need to select the receipient name, the body of the mail is correct.

As soon as the receipient receives the mail, the text in the body has changed. The original body of the mail before sending, as follows:

Your new Software license is: 
6910-9101-1141-0310-1110

Please copy the above license code and activate the new license as follows: 
1. Log into the database 
2. Under the Administrator Tab, click on the Activate License option 
3. Paste the new license number in the License Number field 
4. Click on Save 
5. Click on Activate 
6. Close the form if it did not close automatically.

The mail body after the receipient has received the mail:

Your new Software license is: 
6910-9101-1141-0310-1110

Please copy the above license code and activate the new license as follows: 
1. Log into the database
2. Under the Administrator Tab, click on the Activate License option 3. Paste the new license number in the License Number field 4. Click on Save 5. Click on Activate 6. Close the form if it did not close automatically.

Any idea why?

Thanks

Deon

Access Runtime Functionality

$
0
0

I have a overview database pulling in data from 3 other SQL Databases.

At the front end I use a VB.Net GUI app, to keep the data "Live" I re-query every 5 minutes and also on opening of the Vb.Net app.

When running on my own Laptop with full Access I do not have an issue. When running on other PC's with the run time I get the following:

.....there would have been an image of the Unhandled exception here if my account was already verified!

Anyway it states that it "Cannot create ans Active X component and the exception text does sate xxxxx.xxxxx.reQuery_Access()

I will include an image once I am fully verified.

I am assuming it is due to the limited functionality of Access Runtime, is my assumption correct, if so can anyone advise me of a work around?

Regards

Simon

DLookUp versus call an unbound field

$
0
0

Need a value in a new query Z.  I could:

a. use calculated field alias with a DLookUp i.e.  ABC: Dlookup("This","queryname")

or

b. use a calculated field alias calling a control text box in a Form that is opened i.e. ABC: Forms!FormName.This

In both cases 'This' is not a single number, but is itself derived via a formula involving other fields.  In the query approach (queryname) these fields are joined in; while in the form approach they are calls to fields in forms/subforms that are opened (is not using queryname).

Both work.  I've done both - and I've got control of any gotchas in terms of nulls and such.  The question is efficiency/resource - and whether it matters or not.  The app is big & complex and I want to always avoid running up against the 'too many databases open' type scenario.

As an aside, I believe I've read that a DLookUp used in a query may be not efficient - but that there isn't a choice due to a lack of a common join field so the 'this' value can't be part of the query directly. 

Am wondering in this scenario as to whether the approach used will matter?  advice welcomed

Show records that are 10 days after a datefield

$
0
0

I have people that are registered for an event, where they agreed to pay a downpayment within 10 days of registering. But they have not paid yet, so 11 days after their registration date, I want to alert them to this.

The field with the date in it is [Timestamp], is set as Date/Time, and is shown as: 27-8-2018 15:16:31. The dates are entered in a Google Form's Time/Date stamp and copied and pasted to the database.

I have tried several things, including DateDiff etc.). Nothing works.

If I set up the querylike this:

So basically I am subtracting the date in [Timestamp] from today's date,; the addition of Int() makes sure the time and decimals aren't includede, making everything more readable. This gives me this:

The numbers in Expr1 are correct, that is the number of days between [Timestamp] and today. But why doesn't the identical "phrase" in Criteria work? All the records in my database are shown, instead on only the records where the [Timestamp] is more than 10 days ago?

David


Show field in Reports based on if

$
0
0

I have a report in which I want a certain value shown if there is one entered and N/A shown if none is entered.

I have the field TypUnitReady which is a date field. I am trying to have a code oin the OnLoad field of the report that essentially will Show the Date if one is entered on the form or N/A if nothing is entered.

I tried to have a second field for the null in which one is visible and the other wasn't this is the code I used but it didn't work

    

If TypUnitReady = True Then
    Me.TypUnitReady.Value = True
    Me.Null.Visible = False

Else
    Me.TypUnitReady.Value = False
    Me.Null.Visible = True
End If

Thanks

How to close all openVBA code windows

$
0
0

When I make a project wide change by using Search and Replace ( or any other process where I end up with a lot of open windows in the VBE code panel, I'd like to close them more easily than having to click the close button on each one.  I can't seem to find a Close All action.  Is there one, or should I look through the keyboard shortcuts?

Thanks.

Marj Weir

Error in SQL

$
0
0
Good afternoon. I have an sql instruction like that:

...IN 'CurrentProject.Path & " \ historicoapolice.mdb '" & _ But it gives me error

But if i put like this:

....IN ' C:\loja seguros\ historicoapolice.mdb '" & _ it does not matter anymore.


The "historicoapolice.mdb" is a database to store customer history. In the main MDB there is a button. Clicking executes the sql statement and sends the selected tab to history. It is not connected to the main. I would like the sql statement to run anywhere where the mdb was installed, since the folder is the same for both mdb's.
So, rather than ....IN ' C:\loja seguros\ historicoapolice.mdb '" & _, i would like this......IN 'CurrentProject.Path & " \ historicoapolice.mdb '" & _ But it gives me error. Must doing something wrong, but what?


What i'm doing wrong? Can someone help me? Thank you

Access reports that databases are in an 'inconsistent state'

$
0
0

I found the following post which describes my problem... sort of.  The difference being, I don't have a separate front-end.  The database is just one .mdb file that we all share over a network, including RDP.

https://social.msdn.microsoft.com/Forums/Lync/en-US/9dcbf0df-d1d8-49cb-8efa-86ef985a17b9/front-end-access-db-constantly-getting-quotinconsistent-statequot-error-when-more-than-1-user?forum=accessdev

My preference would've been to reply to that thread stating I have a similar problem, but for some reason, I can't do so.

We're running a Windows 2012 R2 network.  

The problem began last Friday and happened again today, twice.  It repairs itself but how do we stop it from happening?

Macros and Sub-Macros converted to module/functions

$
0
0

I've used macros very little and I've never heard of sub-macros until now.

I have to diagnose a problem with a database I've never worked on before. All the code is in macros.

To make it easier for me to understand, I converted the macros involved to modules.

However, I'm confused by the sub-macros.

The macros are run from a form with the syntax 'macro.sub-macro'

When the macro is converted to a module, the sub-macros become separate functions but how to I execute them and pass the parameters?

Below is some sample converted code. What is 'CodeContextObject' and how does the '.Preparation' value get passed when running the function?

Function MSwitchboard_Preparation()
On Error GoTo MSwitchboard_Preparation_Err

    With CodeContextObject
        If (.Preparation = 1) Then
            DoCmd.SetWarnings False
        End If
        If (.Preparation = 2) Then
            ' QImportToData
            DoCmd.OpenQuery "QImportToData", acViewNormal, acEdit
        End If

    ......





Viewing all 14673 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>