News, links, downloads, tips and tricks on Microsoft Access and related

About Me Search
Name:Alex Dybenko

Location:Moscow, Russia

Friday, December 24, 2010

Linked tables – wrong index as primary key

When Access picks wrong unique index as primary key for linked table – you have to rename Primary key so that it appears first alphabetically.

Labels: ,

Tuesday, December 21, 2010

Browse for folder – new folder button

You are normally using SHBrowseForFolder API function to let user browse for folder, sample code you can find at or In order to show "Make new folder" button on this dialog you need to set following flag:

.ulFlags = .ulFlags Or &H40


And MSDN BROWSEINFO Structure page lists other flags you can set for that dialog.

Labels: ,

Sunday, December 12, 2010

DAO RecordsAffected property

RecordsAffected property returns the number of records affected by the most recently invoked Execute method. Can be useful when you need to update a record in a table, and if record not exists – add it. Normally this is solved by opening recordset and using NoMatch property to test if record exists. Using RecordsAffected property you can do this in 3 lines:

Dim dbs As DAO.Database
Set dbs = CurrentDb
dbs.Execute "UPDATE Sales SET Amount=Amount + " & _
varAmount & " Where SalesDate=" & varDate, dbFailOnError
If dbs.RecordsAffected = 0 Then
dbs.Execute "INSERT INTO Sales (Amount, SalesDate) Values(" _ & varAmount & ", " & varDate & ")", dbFailOnError
End If

Labels: ,

Wednesday, December 08, 2010

Programmatically create ActiveX control on Access form

To create new control on Access form in design mode you can use CreateControl function, works fine for native controls, but for AcitveX controls (acCustomControl argument) it creates only empty container. Where can you set which control you want to create? The trick is to copy OLEData property from existing control to just created:

Dim frm As Form, ctl As ControlSet
frm = Forms("MyForm") 'Make sure it is opened in design mode Set ctl = CreateControl(frm.Name, acCustomControl, acDetail, , , 100, 100, 200, 200)
ctl.OleData = frm("cmd001").OleData 'cmd001 already exists on that form, or other opened form
ctl.Name = "cmd002"

Labels: ,

Wednesday, December 01, 2010

Visual Basic for Windows Phone Developer Tools

Visual Basic for Windows Phone Developer Tools – RTW:  Now we can build applications for Windows Phone 7 using VB.NET. Some sample applications to start with. Time to get new phone…

Labels: ,