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

Shared folder has MS Access Databse[.mdb], client use ODBC to acess database file, the last insert row missing on client.

$
0
0
here are 3 PCs, 1 is server, other 2 are clients.
1.Server[WIN10] has the shared folder which saved mdb file, and run our application, this application use ODBC to access mdb.[Not use DNS, just use ]
ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};UID=;PWD=;DBQ=C:\DBFile\Formulation.mdb; [C is local driver]
2.Client 1[WIN7] is running our application, use ODBC to access the remote mdb file.[Read and write]
ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};UID=;PWD=;DBQ=Z:\DBFile\Formulation.mdb; [Z is remote driver]
3.Client 2[WIN10] is running our application, use ODBC to access the remote mdb file.[Read and write]
ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};UID=;PWD=;DBQ=Z:\DBFile\Formulation.mdb;
[Z is remote driver]

CRecordset is used in our code to access database, and the application already close connection and reopen connection when the network come back.

The issue is:
Step 1: The Client 1 disconnect network.
Step 2: Add one record into table1.
Step 3: Connect network for Client 1.
The new record can be display by Client 2, but can't be display by Client 1.

If I copy the database file in Client 1 to local driver, then the application can get the new record.
It seems the network driver has cache bug.

Any one can help me on this issue?
Thanks very much!

This issue is hard to be reproduced

Date Compare Function

$
0
0

Hello All,

Apologies if this is an obvious solution, I am relatively new to Access, this is my first database not just managed in Excel. I’ve completed some uDemy courses which covers most of what I need, however there is one feature I would like to implement which I have not been able to.

The situation is that I have an Access 365 database, which stores requests from staff for shifts. As part of entering this data I want the form to reject applications where the cut off date for a given roster has gone by. I have created a table which has three columns; “RosterStart”, “RosterFinish”, and “CutOffDate”. In Excel I had used a combination of the OFFSET and the MATCH function to find the cut-off date from an inputted date against a lookup table, how could this be achieved in Access?

In short, I am looking for the database to look for which roster the entered date falls under, then look at the CutOffDate for that roster, compare it against system date, and generate an error, as needed.

Your assistance would be greatly appreciated.

Access Local Table, with multiple users, who click exact same time issue

$
0
0

I have a legacy 2007 mdb set up for multiple users.  It is not a split mdb.  There is a function that adds rows to a local table.  A button-click fires off this function.  If two users happen to click at the exact same time, one of the users gets an error message that "The changes you requested to the table were not successful because they would create duplicate values...".  If they click at separate times, this error does not occur.

Currently the code to open the table is:  SET rst = db.OpenRecordset("tablename", dbOpenDynaset)

I do not know enough about Access to know what recordset options to use to keep this error from happening.

I read about ADO recordsets and changed the code to open the table to this:

rst.Open "tablename", CurrentProject.Connection, adOpenDynamic, adLockPessimistic

This did not solve the issue.

What recordset options would allow this function to run if two users happen to click at the same time?

Thanks.


Prevent duplictes when inputting data

$
0
0
We have a MS Access 2016 database.  Every day multiple people report there stats.  Stats are recorded against employee and a date; occasionally two identical records are created.  We are in a secure environment and cannot use Macros.  How can I set the input form to warn of or stop a duplicate record for same person on same day?  That is if I put in John Citizen 7/1/20 (name is from dropdown) how can prevent same date name combination to be used?  I vaguely remember you could set two keys but I cannot recall how to do this.  Thanks

32bit --> 64 bit object not found

$
0
0

we have to migrate from 32 bit to 64 bit version.

i do not have any experience with that and i heritated the database and i'm looking for help

this is the code

 
Function GetEmailFromNonDefaultInbox()
    Dim myOlApp As New Outlook.Application
    Dim myNameSpace As Outlook.NameSpace
    Dim myInbox As Outlook.MAPIFolder
    Dim myitems As Outlook.Items
    Dim strFilter As String
   
    Dim ns As NameSpace
    Dim Inbox As MAPIFolder
    Dim SubFolder As MAPIFolder
    Dim Item As Object
    Dim Atmt As Attachment
    Dim FileName As String
    Dim MyDocPath As String
  
    Dim wsh As Object
    Dim fs As Object
    Dim TempRst As DAO.Recordset
    Dim rst As DAO.Recordset
 
  
    Set myAccounts = myOlApp.GetNamespace("MAPI").Stores
    For i = 1 To myAccounts.Count
      
        If myAccounts.Item(i).DisplayName = "Bxxxxx" Then
            Set myInbox = myAccounts.Item(i).GetDefaultFolder(olFolderInbox)
            Exit For
        End If
    Next
    
 
 Set db = CurrentDb
    Set TempRst = CurrentDb.OpenRecordset("myfile")
    
    Set ns = GetNamespace("MAPI")
    Set Inbox = myAccounts.Item(i).GetDefaultFolder(olFolderInbox)
    Set SubFolder = Inbox.Folders("Bxxxxxsubfolder")

' rest of the code
end function

and i get this error in this line : 

Set SubFolder = Inbox.Folders("Bxxxxxsubfolder")

Excel Import Subscript Out of Range Error with seemingly identical databases

$
0
0
I've created two identical tables in two different databases.  The one gets no subscript errors, the other does.  I've triple checked that all the field names and properties are IDENTICAL.  Are there any other factors that would be causing the subscript error?

Intermittent corruption Problem

$
0
0

I have a access 2013 front end/back end configuration.  It is very simple, only one table and two forms and a couple reports.  Periodically, for no apparent reason I get the following error.  At this point users cannot get the front end to run.

The only way I can fix it is to Import all its objects into a new DB.  Can anyone think of what might be causing this?

VBA code will not continue after running DoCmd.DeleteObject command.

$
0
0

I am attempting to create code that will first delete a query in the database and after it creates it do do additional items. But the code automatically stops after it deletes the query (it will not even run a message command).

Anyone have any ideas why it is doing this?


"File not found" when closing the App and clicking a button

$
0
0

Hi

I have been working on an App for years. Worked yesterday. Today I get this message when I close the App and when clicking any button wtih an event procedure.

And there all stops. The App cant be closed. Ony way is the hard way via Ctrl-Alt-Del

The only differences, compared to yesterday, are some new Forms.
I have deleted all new Forms, but still the App cant be closed.

I have run Compact & Repair.

Any ideas why and how to fix this?


Cheers // Peter Forss Stockholm

How Best To Distribute Compiled Access Application to Many Users

$
0
0

I have written a complex application in 32-bit Access that just went into beta testing, and already a couple hundred people are interested in getting it. Of course, I don't want to give away my source code, so I am only distributing the compiled version, in an .accdr file.

The problem is that some of the beta testers have 64-bit Office installed on their computers, and they cannot even run the 32-bit Access Runtime I send out with the install package. The 32-bit file.accdr will not run on their 64-bitness Office computers.

My question: WHAT'S THE BEST WAY to distribute this program to this wide variety of users/customers?

My KLUDGE answer is to compile the program a second time, on a different computer with 64-bit Access, and send out both file32.accdr and a file64.accdr and they can use whichever one works for them.

I'm hoping someone out there has a more elegant solution. TIA for any help.

How to check Null in a Combobox

$
0
0

Hi

I need to check there is a value in a combobox.

In one Form I have this code and it works:

    If (Eval("[Forms]![InventeringMalt]![Warehouse] Is Null")) Then
        Beep
        MsgBox "Please register the warehouse", vbOKOnly, """"
        End
    End If

But when I try the same (simular) on another Form the code is ignored.

I want this:

On a MainForm I have a combobox "Warehouse"
On the same MainForm there is a Pusbutton.
If no Warehouse is selected I want a MsgBox "Please register the warehouse"

I thought it was an easy one. But no success.

Please help



Cheers // Peter Forss Stockholm

Difference between MS Access Database Engine 2010 and MS Access Database Engine 2016

$
0
0
Hi all,

In my App i use multiple connection at same time. If i use MS Access Database Engine 2010 all connection working well but if i try use MS Access Database Engine 2016 connection to dtb some times fail.

Is there some limits for connections in MS Access Database Engine 2016 ?

Thx

BR

ODBC Delete on a Linked Table Failed

$
0
0

I am trying to delete all records in a SQL table

I tried a delete query and DoCmd.RunSQL "Delete * From table name"

The DoCmd.RunSQL command worked when the table was Access

The delete query runs if I open it directly but not with a VBA DoCmd.OpenQuery

Both result in the same Access Error 3156, SQL Server Native Client 11.0 query expired

The delete query runs for about 3 seconds when I open it directly

Access 2016 front end, SQL Express 2017 on Win 2012 server

Chart in report view is ok, in print preview is much larger

$
0
0

I have designed a report with a chart. It looks great in report view, but resizes itself in print preview. Any idea why this is happening and how I can get it to stop?

Thanks

See attached pics.


JG

Query '' is corrupt in Excel automation

$
0
0

The Query '' is corrupt error is currently being experienced in Excel automation. This problem started occurring after KB4525237 and/or KB4523203 were implemented. When will Microsoft be fixing this issue? Thanks.

Tomas Gonzales

 

Attaching image to table (Local Images) to an Attachment field access 2016

$
0
0

I am trying to add image to an image field in a table in Access 2016 using VBA

Here is the scenario:

Table contains field for attachments named [Photo]

Table = [Term]

The photos (over 3,000) all have the ID number in the file names but are numbered (Several Photos for one record)

So the file names that go with the Record ID  examples: 1-160304-0-t1.png; 1-160304-0-t2.png; 1-160304-0-t3.png; 1-160304-0-t4.png; 1-160304-0-t5.png

With the LEFT 1-160304 being the record ID

Here is something that might be helpful, there is a field in the database [ImageName] that refers to image file name, but it contains the wrong format: 1-160304-0-t1.jpg for 1-160304-0-t1.png, this is easily fixed so that file name "MIGHT" refer to the image I need to attach via VBA. So I could use this Field [ImageName] to match the file I need to upload.

So I am looking for example code to do this,

Taking the file name from a field matching the appropriate image file and then attaching it to the attachment [Photo] field in the Access 2016 table

I can insert one image using the VBA LoadFromFile but I am having a hard time getting this to do all records.



excel to nested xml

$
0
0

Hi,

I am trying to create nested xml from an excel sheet which I get from API.

Column A is Parent and Column B is Child in the excel sheet. A child will have many sub childs. So I am checking the condition and trying to create a nested xml but couldn't succeed. Any help is highly appreciated.

Sub xlsToxml()

Dim fso, oExcel, wb, ws
' create file system object
set fso = WScript.CreateObject("Scripting.Filesystemobject")
' create Excel application object
set oExcel = WScript.CreateObject("Excel.Application")
oExcel.Visible = True

' create xml file path
set XmlFile=fso.CreateTextFile("C:\Backup-44069411\C folder\Englobe\gsh.xml", True, True)

' creating xml file components
'XmlFile.Write("<?xml version=""1.0"" encoding=""utf-8""?>"&vbNewLine)
XmlFile.write("<Country>"&vbNewLine)

'reading contents from excel file
set wb = oExcel.Workbooks.Open("C:\Backup-44069411\C folder\Englobe\GSH\sample_gsh.xlsx")
set ws = wb.Sheets(1)

'getting the count of rows in the excel
Row_count = ws.UsedRange.Rows.Count
MsgBox Row_count

DirectHolder = ws.cells(2,1).value ' Read the 1st column each row
Subsidiary = refinedVal(ws.cells(2,2).value)' Read the 2nd column each row
GroupAbbreviation = refinedVal(ws.cells(2,3).value)' Read the 2nd column each row
VotingPercentage = refinedVal(ws.cells(2,4).value)' Read the 2nd column each row
GroupInterestPercentage = refinedVal(ws.cells(2,5).value)' Read the 2nd column each row
Jurisdiction = refinedVal(ws.cells(2,6).value)' Read the 2nd column each row
RegisteredAddress = refinedVal(ws.cells(2,7).value)' Read the 2nd column each row
Country = refinedVal(ws.cells(2,8).value)' Read the 2nd column each row
XmlFile.write("<Parent>"&Parent&"</Parent>"&vbNewLine)
XmlFile.write("<Child>"&Child&"</Child>"&vbNewLine)

For i=3 To Row_count
	
	previous_parent = refinedVal(ws.cells(i-1,1).value)
	previous_child = refinedVal(ws.cells(i-1,2).value)
	' checking condition for previous values	
	If StrComp(ws.cells(i,1).value, ws.cells(i-1,1).value, vbTextCompare) = 0 Then
		XmlFile.write("<Parent>""</Parent>")
		XmlFile.write(vbTab)
		XmlFile.write("<Child>"&Subsidiary&"</Child>")
		XmlFile.write("<Child>"&GroupAbbreviation&"</Child>")
		XmlFile.write("<Child>"&VotingPercentage&"</Child>")
		XmlFile.write("<Child>"&GroupInterestPercentage&"</Child>")
		XmlFile.write("<Child>"&Jurisdiction&"</Child>")
		XmlFile.write("<Child>"&RegisteredAddress&"</Child>")
		XmlFile.write("<Child>"&Country&"</Child>")
		XmlFile.write(vbCrLf)
	End If
	If StrComp(ws.cells(i,1).value, ws.cells(i-1,2).value, vbTextCompare) = 0 Then
		XmlFile.write("<Parent>""</Parent>")
		XmlFile.write(vbTab)
		XmlFile.write("<Child>"&Subsidiary&"</Child>")
		XmlFile.write("<Child>"&GroupAbbreviation&"</Child>")
		XmlFile.write("<Child>"&VotingPercentage&"</Child>")
		XmlFile.write("<Child>"&GroupInterestPercentage&"</Child>")
		XmlFile.write("<Child>"&Jurisdiction&"</Child>")
		XmlFile.write("<Child>"&RegisteredAddress&"</Child>")
		XmlFile.write("<Child>"&Country&"</Child>")
		XmlFile.write(vbCrLf)
	REM Else
		REM XmlFile.write("<Parent>"&Parent&"</Parent>"&vbNewLine)	
		REM XmlFile.write("<Child>"&Child&"</Child>"&vbNewLine)
	End If
Next
XmlFile.write("</Country>"&vbNewLine)

wb.close ' closing the excel sheet that was opened
oExcel.Quit ' deleting excel object resources
MsgBox("Done")

	
End Sub



Function refinedVal(nodeValue)  
   Dim sval
   If IsNull(nodeValue) Then  
     refinedVal = ""  
   Else  
     sval = CStr(nodeValue)  
     sval = Replace(sval, "&", "&amp;") 'do ampersand first !  
     sval = Replace(sval, "'", "&apos;")  
     sval = Replace(sval, """", "&quot;")  
     sval = Replace(sval, "<", "&lt;")  
     sval = Replace(sval, ">", "&gt;")  
     refinedVal = sval  
   End If  
End Function


call xlsToxml


I am just getting a flat xml tree instead of nested one.

Access - search across multiple base tables (SELECT with JOINs) & show results in parent form and subforms

$
0
0

Background - there exists the following for a residential property database:

Tables in SQL Server 2017

  • H_ADDRESS
  • H_IMPROVEMENT

Access 2016

  • Linked tables to those in SQL Server
  • Parent Form - frmSales
  • Sub Form - frmImprovement

So the parent form, frmSales, contains subforms e.g. frmImprovement. I'm not wanting to deviate from parent and subforms.

Requirement

Provide the user two search methods - simple and advanced.

Simple

A new form will be created that has fields for basic search parameters like city (address), year built (improvement), etc. This form will need to run a query that does SELECT with JOINs and WHERE conditions for the values of the search parameters. I know how to write the query. How do I get a button to run the query and open the parent and sub forms with the result set?

Advanced

I'd like this to work like Filter by Form -- the user views the parent and sub forms, initiates a search, enters search values, runs search (the SELECT with JOINs), and views the result set. Is it possible to have the parent and sub forms support something equivalent to Filter by Form? (doesn't have to actually be Sort & Filter > Filter by Form out of the box... vba custom code is agreeable)


How to use case with inStr

$
0
0

SELECT Company_name, left(company_Address,  CASE WHEN instr(company_Address,",") -1) = 0 THEN LEN (company_Address) ELSE instr(company_Address,",") -1 END)
FROM Company;

I am trying to use case with inStr. what is the correct syntax for CASE in Access

How can we detect a access Form has been moved on the screen

$
0
0

How can we detect a access Form has been moved on the screen ?

We dont asked for changed. We know it is resize.

Resize dont registrate the form is moved

Viewing all 14673 articles
Browse latest View live


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