access-vba

How to save calculated values in MS Access

一世执手 提交于 2019-12-24 14:22:00
问题 I have a textbox in a form that I created. I want to add an expression in the textbox's Control Source property. I also want to bind the textbox to a field in the table using Control Source propety of the textbox. Is there any way I can add a field name and an expression in the control source property of a particular textbox? The expression basically adds up couple of numbers and displays the output in that textbox. And I want the output to be stored in a field in the table. 回答1: You could

Get the name of local table and linked table in vba

♀尐吖头ヾ 提交于 2019-12-24 13:52:36
问题 I have five tables in my application in which two are local table and three are linked table, I'm not sure about my code how to get name of table. I want a code for provide me name of both type of table name separately using for loop. Table Name LocalTable1 LocalTable2 LinkTable1 LinkTable2 LinkTable3 Code Dim td As TableDef Dim stConnect As String For Each td In CurrentDb.TableDefs Debug.Print td.Name Next 回答1: You can use the source table name: Dim db As Database Dim tdf As TableDef Set db

VBA tool to determine SpreadsheetType from given spreadsheet

自古美人都是妖i 提交于 2019-12-24 13:42:46
问题 I wish to use the TransferSpreadsheet command to link or import a spreadsheet to Access 2010. It requires a value for SpreadsheetType (drawn from the AcSpreadSheetType enumeration). What is the Access VBA tool to determine SpreadsheetType from given spreadsheet filename? Maybe the only means is to examine the file extension and do a lookup? If you've solved this problem before, please share. 回答1: Given that there seems to be a definite one-to-many mapping from file extension to specific Excel

Can't add new field after deleting fields

自古美人都是妖i 提交于 2019-12-24 13:41:28
问题 I am using MS Access 2010. Situation: Table reach 225 fields Delete one field (so there is 224 fields "visible" in the table) Add new field Get error 3109 "Too many fields defined." I add and delete fields with VBA. Add: Dim dbs as Database Set dbs = CurrentDb() queryAlter = "ALTER TABLE [Table] ADD [" & [field] & "] Varchar(255)" dbs.Execute queryAlter, dbFailOnError dbs.Close I add a field with a query because its easier for me Delete: Dim dbs as Database Dim field as Field Set dbs =

Counting characters in an Access database column using SQL

拜拜、爱过 提交于 2019-12-24 13:39:28
问题 I have the following table col1 col2 col3 col4 ==== ==== ==== ==== 1233 4566 ABCD CDEF 1233 4566 ACD1 CDEF 1233 4566 D1AF CDEF I need to count the characters in col3, so from the data in the previous table it would be: char count ==== ===== A 3 B 1 C 2 D 3 F 1 1 2 Is this possible to achieve by using SQL only? At the moment I am thinking of passing a parameter in to SQL query and count the characters one by one and then sum, however I did not start the VBA part yet, and frankly wouldn't want

Email address validation for MS Access table

依然范特西╮ 提交于 2019-12-24 13:33:39
问题 My table has the following validation in the "Validation Rule" Section of an Access table that keeps most the email addresses I enter clean: Like "? @? .?? " And Not Like " [!a-z@=.^_$%!#&'`{|} ?~/-] " and . However, it still lets in stuff like Bla.Bla@testing.co.u I found this link for JavaScript. It does a much better job than mine and would filter out the kind of email addresses mentioned above. How to validate an email address in JavaScript How would it look for MS Access? Function or

Access VBA image copy

时光怂恿深爱的人放手 提交于 2019-12-24 12:33:19
问题 I have a report generated by my access program. Each record in the report has a picture that is stored externally and referenced with a file path. I want to have a way for my users to copy the pictures so they can paste them into an email or document. Since the pictures are stored externally the copy function is not available from the right click context menu. Is there a way I can add in a button and use VBA to get the picture from the file path and place it in the clipboard? 回答1: You can try

Disable Import errors table in Ms Access

拜拜、爱过 提交于 2019-12-24 11:59:35
问题 Just to start with , I am not a very experienced programmer in Access. Is there any way I can disable the import error tables which are auto generated by access when you import files from excel ? The reason I want to do this is my excel file has about 4000 rows with data about different locations,now the location I have to do the reporting on is importing properly thats why I am not worried about about the import errors . Also, it only detects the error in one row and because I import the

Controlling size of forms in Access

独自空忆成欢 提交于 2019-12-24 11:44:06
问题 So I have an Access application, and I'd like some forms to be maximised when they are opened, and others to be medium-sized when they are opened. However, if I try something like this: Private Sub Form_Activate() DoCmd.Maximize End Sub or Private Sub Form_Activate() DoCmd.Restore End Sub it has the effect of maximizing or restoring every open window, which isn't what I'm looking for. Is there any way around this? I'm using Access 2003. 回答1: ΤΖΩΤΖΙΟΥ is 100% right when saying that either all

Programmatic changes to form won't save

谁说胖子不能爱 提交于 2019-12-24 11:35:59
问题 Does anyone have an idea what could prevent either of these commands from actually saving a form? Is there a setting I'm missing that could make the form "read-only"? I'm toggling the control.enabled property on the form on load, but I can't seen to make it stick once I've closed the form. DoCmd.Close acForm, Me.Name, acSaveYes DoCmd.Save acForm, Me.Name Edit: Some psuedo code to clarify. This function runs on form load to enable/disable certain controls and works 100% as expected. Private