access-vba

Access VBA recordset string comparison not working with wildcard

夙愿已清 提交于 2019-12-24 03:44:35
问题 I have loads of experience using VBA in Excel but very little experience using VBA in Access 2010. I'm trying to delete records from a recordset where one of the fields ends in "_X". When I use a wildcard the comparison fails. When I use a specific string, the comparison works as expected. Here is the Code that I am using. Dim db As Database: Set db = CurrentDb Dim tbl As Recordset: Set tbl = db.OpenRecordset("WRITEON") With tbl Do Until .EOF If ![ACOD] = "*_X" Then '"$ICP_X" works Debug

Inserting date into string

可紊 提交于 2019-12-24 03:44:34
问题 In VBA, I am setting a field in a form equal to a string like so: tmpNum=1 me.field="DD" & Format(DATE, "mmddyy") & tmpNum For today I would want me.field to be DD0428151 but instead the whole Format(DATE, "mmddyy") statement seemingly does nothing and I get DD1 in the form. Does anyone understand why the date isn't appearing in my string and how to fix it? 回答1: Strange things like this can happen if you have a field named Date in your table and/or a control named Date on your form. They will

Alter Table doesn't work under MS Access 64 bit. Why?

不问归期 提交于 2019-12-24 03:27:58
问题 I am trying to write a simple function to resize a text field in MS Access 64 bit version under Windows 7. It fails with the error 3420, object invalid or no longer set. Why is this? Can't you alter a table in code anymore under MS Access 64bit version? Here is the code: Private Function ResizeSingleTextField(sTableName As String, _ sFieldName As String, _ iLength As Integer) ResizeSingleTextField = False Dim sSQL As String sSQL = "ALTER TABLE " & sTableName & " " _ & "ALTER COLUMN " &

Calling a Function from Macro Design In Access

て烟熏妆下的殇ゞ 提交于 2019-12-24 03:15:37
问题 I have written some sql queries, some sub procedures and have some saved imports. Now I am trying to use the Macro Design in Access to provide a run button which will run these objects sequentially. However I dont see any command for running a sun procedure, I can see OpenVisualBasicModule and Runcode. OpenVisualBaicModule is only opening my sub procedures and Run Code is asking for a function only. I created a function with all the sub procedure call inside. But thats not working while

Group by with UNION

牧云@^-^@ 提交于 2019-12-24 02:35:16
问题 My code is not grouping properly, it still doesn't group [Reden uitstroom2] and [Reden uitstroom3] with [Reden uitstroom1]. The count works properly but its showing duplicates in [Reden Uitstroom1]. For Example: Reden uitstroom1 = 1x A / 2x B Reden uitstroom2 = 1x A / 1x B Aantal Uitstroom 2014 - Reden Uitstroom1 1 - A 1 - A 2 - B 1 - B Which Should be: Aantal Uitstroom 2014 - Reden Uitstroom1 2 - A 3 - B I can't seem to change [Reden Uitstroom1] into [Reden Uitstroom] because then it returns

separating code from data in access

你说的曾经没有我的故事 提交于 2019-12-24 02:28:18
问题 I am extending an access application at the same time that some users are using it. This means that users are changing databases. I created a backup of access file and working on it. In this way I can make sure that I am not making any changes to system that change database when I am testing the system. But I only can develop when users are not using the system and hence they are not changing databases (data in tables). This is not good since I cannot work at the same time that users are

Foreign characters show up as ????? in VBA 2003, how to set up UTF-8?

冷暖自知 提交于 2019-12-24 02:25:50
问题 I have a Database in Access 2003 that needs to work with foreign language characters. The characters show up fine in the table. However, when VBA tries to read them it cannot do it. As an example, the column ANSWER_TEXT from cf_Answer displays: 佛吉尼亞海灘 But a select statement in VBA: sqlstmt = "SELECT ANSWER_TEXT AS ans_text FROM cf_Answer" Set rst_a = dbs.OpenRecordset(sqlstmt, dbOpenSnapshot) rst_a![ans_text] returns ?????? . I know this has something to do with UTF-8 encoding but I cannot

Supporting multiple versions of Excel for automation from an Access application

穿精又带淫゛_ 提交于 2019-12-24 02:22:51
问题 I have an Access app, developed in Access 2013 in multi-user env, uses Excel automation to export and format an Excel file. The normal Office/Excel 2013 (15.0) references have been made and all works well on Office 2013 machines. Does not play nicely on 2010 machines. Using a 2010 machine, I replaced the 15.0 references with 14.0 references, and the app is happy on 2010 and 2013 machines. Upon next edit/update on my 2013 machine the 15.0 references return. Any suggestions to more conveniently

Detect new record and obtain ID using Access VBA

…衆ロ難τιáo~ 提交于 2019-12-24 02:14:19
问题 Related to this question, how do I detect that a form user is adding a record? It would be ideal if I knew this as soon as the form's "current record" became "new" (navigating beyond the last existing record, or clicking the "new" navigation button), but knowing as soon as the first piece of data begins to be entered would be almost as good. I'm guessing that this would be testing something in Form_Current() , but what (or is there a better way)? Further related, what is the earliest that I

recordset.find using variable VBA ADODB

六眼飞鱼酱① 提交于 2019-12-24 01:12:28
问题 I am getting pretty desperate trying to get this trivial search to work: rst2.Find "ID = '" & messID & "'" I have tried just about any combination but it just never returns a search result. the whole code would be here: Option Compare Database Option Explicit 'Modul zum Updaten des Status eines Messmittels in der Stammdatenbank (Entnommen/Verfügbar)3 Public Function updateStatus() Dim rst2 As ADODB.Recordset Dim rst As ADODB.Recordset Dim messID As String Set rst = New ADODB.Recordset