access-vba

TransferText export to CSV not working, but TransferSpreadsheet to XLSX working

安稳与你 提交于 2019-12-24 00:34:43
问题 I created a Form in which I created a button and through the context menu I activated the Code-generator for VBA. On a click on the button, the query is correctly exported as .xlsx: Option Compare Database Private Sub Befehl0_Click() DoCmd.TransferSpreadsheet acExport, , "queryname", "C:\test\queryname.xlsx", -1 End Sub However, when I modify the export (according to this FAQ): Option Compare Database Private Sub Befehl0_Click() DoCmd.TransferText acExportDelim, , "queryname", "C:\test

.Body text when creating Outlook email is double-spacing no matter the new line command used

只愿长相守 提交于 2019-12-24 00:22:22
问题 I'm creating an Outlook e-mail through VBA that runs off an Access form button click. For the .Body, I'm setting my 'strBody' string object using the following concatenated string: strBody = "First Line of text here." & vbNewLine & _ vbNewLine & _ "Second Line of text here." & vbNewLine & _ Chr(187) & "Third Line of text here." & vbNewLine & vbTab & _ Chr(187) & "Fourth Line of text here." & vbNewLine & vbTab & _ Chr(187) & "Fifth Line of text here." & vbNewLine & vbTab & vbTab & _ Chr(187) &

Where do I put Access vba code to only fire when physically printing?

吃可爱长大的小学妹 提交于 2019-12-23 23:00:42
问题 I have some code that I want to fire when the user physically prints the report. Not when Print Previewing, etc, but only when sending to the printer. The user needs to be able to pull up the report and view it, then if they decide to print, the vba code will take over and write some info to a different table than is being used to generate the report. I was hoping not to have to place a Print button on the actual report (even though I know I can hide it for the print), so I was wondering if I

Is it possible to click on a report record to open relevant form in Access using VBA

两盒软妹~` 提交于 2019-12-23 22:46:31
问题 I have a report with details of jobs/tasks, and also a form which contributes the majority of the data towards that report. Given that a report is a nice way of looking at the larger picture of the data, and a form is the best way of editing data, I would like to be able to click on a row, and have it open up the relevant record in the form view. Does anyone know how to do this through VBA? In my mind it should be possible, though my knowledge of objects in Access is limited. Update I've

How to specify Primary Key when using vba to create tables

泪湿孤枕 提交于 2019-12-23 18:48:13
问题 I've updated the code with the suggestion given below, which I've tested and works great, for quick reference for future users. I'm using the below code to create linked tables without having to set up a DSN for each user, how can I specify a primary key as you would be asked if connecting manually: Dim sConnect As String Dim db As DAO.Database Dim tdf As DAO.TableDef Set db = CurrentDb Set tdf = db.CreateTableDef tdf.Name = "dbo_vwFeedback" ' - -- --- This is the Label that you see in Access

access 2007 bug - intermittent query parameter prompts

不羁岁月 提交于 2019-12-23 16:19:39
问题 I am working on an Access 2007 application that was created by someone else. It has a strange, intermittent bug in which it prompts the user for query parameters when the main form is opened. The query parameters are clearly not necessary, because the error does not always occur. The very strange "fix" to this problem is to open and close a particular module before opening the main form. Then the form opens without parameter prompts. However, of course I can't ask end users to open and close

VBA OpenRecordset Produces Error 3061

允我心安 提交于 2019-12-23 15:48:37
问题 databasename = "qryDataExport" Dim grpfield As String grpfield = "Group" Dim keys As DAO.Recordset groupcmd = "SELECT [" & databasename & "].[" & grpfield & "] FROM [" & databasename & "] GROUP BY [" & databasename & "].[" & grpfield & "]" Set keys = CurrentDb.OpenRecordset(groupcmd, dbOpenSnapshot) The above produces "Error 3061: Too few parameters. Expected 13." when run. My reading thus far has heavily implied that this is likely a spelling issue with improper field titles or an issue

Clear All fields after Hit the Save button

和自甴很熟 提交于 2019-12-23 15:40:10
问题 I have working on forms, after i filled all the fields and Click on Save button, all fields have been saved but the text fields was not empty, all entered text still present, How do removed those text after hit on the save button 回答1: Go to a new record: DoCmd.GoToRecord , , acNewRec 回答2: May be you would like to add the following in the click on save button event before "End Sub" Me.TextboxName.Value = Null 回答3: Try this routine linked to a button you want to click to clear all textboxes in

How to get monitor size

China☆狼群 提交于 2019-12-23 12:48:22
问题 In my project I need to determine the size of the monitor/screen. I can get the screen resolution using following code X = fPixelsToTwips(GetSystemMetrics(SM_CXSCREEN), "X") ' Y = GetSystemMetrics(SM_CYSCREEN) This gives me the correct screen resolution. But I have a 13.6" laptop screen and my friend has 15.6" laptop screen. Both has same screen resolution 1366*768. But the screen size is different. So how can I determine screen size of monitor? This is very important for my project. 回答1: You

How to use rst.FindFirst with rst.NoMatch?

北城余情 提交于 2019-12-23 09:47:32
问题 My code works except for this one line .FindFirst "[DONOR_CONTACT_ID] = strTemp2" I want my code to check if there is a record, where a specific DONOR_CONTACT_ID exists becaue there are multiple records with the same DONOR_CONTACT_ID. If that record does not exist, then I want to add that DONOR_CONTACT_ID and RECIPIENT_CONTACT_ID to RECIPIENT_1. If that record does exist, I want to add the RECIPIENT_CONTACT_ID to RECIPIENT_2 for that specific DONOR_CONTACT_ID. To do this, I used .FindFirst,