access-vba

How can I sort by date in ms access 2007?

依然范特西╮ 提交于 2019-12-23 00:51:08
问题 Just want to know how do I sort a text column that shows data in date format mm/dd/yyyy. 回答1: You will first have to convert to a date to get a proper sort. This is a query that converts Datetext to RealDate, and then sorts on that column (field). You can also click the header to choose the sort order. SELECT t.ID, t.Datetext, DateSerial(Mid([Datetext],InStrRev([Datetext],"/")+1), Mid([Datetext],1,InStr([Datetext],"/")-1), Mid([Datetext],InStr([Datetext],"/")+1, (InStrRev(Datetext,"/")-InStr(

VBA access: Refreshing a form from another form's code

与世无争的帅哥 提交于 2019-12-22 17:38:58
问题 EDIT: nevermind someone helped me. form_(name).recalc or form_(name).refresh: form_main.recalc I have two forms: "main", "details". In the "main" form, I have a button that opens "details" in a dialog. The problem is that I have a checkbox in "details" and when in changes, I need to refresh "main". What command do that? Thank you 回答1: I'm going to provide a different answer than the one you discovered for yourself: Open the detail form with the acDialog switch, and then requery when it is

Using @@Identity

不想你离开。 提交于 2019-12-22 05:11:31
问题 I'm wondering how I could get the most recently generated autonumber value from a table in another db. Currently I am doing this: Do Until rsA.EOF 'Inserts new row here (works) Set rs = New ADODB.Recordset rs.Open "SELECT @@Identity" (Connection info) SQLcmd = "UPDATE tbl SET col = " & rs("SELECT @@Identity").Value & " (WHERE statement);" DoCmd.RunSQL SQLcmd rsA.MoveNext Loop But its giving col a value of 0 instead of the newly generated autonumber. Any idea why? Or another way to do this?

Using @@Identity

自古美人都是妖i 提交于 2019-12-22 05:11:03
问题 I'm wondering how I could get the most recently generated autonumber value from a table in another db. Currently I am doing this: Do Until rsA.EOF 'Inserts new row here (works) Set rs = New ADODB.Recordset rs.Open "SELECT @@Identity" (Connection info) SQLcmd = "UPDATE tbl SET col = " & rs("SELECT @@Identity").Value & " (WHERE statement);" DoCmd.RunSQL SQLcmd rsA.MoveNext Loop But its giving col a value of 0 instead of the newly generated autonumber. Any idea why? Or another way to do this?

Is it possible to fetch gmail emails using VBA?

こ雲淡風輕ζ 提交于 2019-12-22 00:28:33
问题 I'm trying to drop Outlook from my MS Access application. The main problem is to fetch emails from my gmail account and for example delete it or read the body etc. I know I can use CDO to send email from VBA using my gmail account, but is it possible to get my inbox using VBA? Thanks. 回答1: I have found the solution. There is a library you can use to fetch emails from using IMAP or POP3 protocol via VBA http://emailarchitect.net/eagetmail/kb/vb.aspx 回答2: You would need some type of

Get contents of laccdb file through VBA

会有一股神秘感。 提交于 2019-12-21 04:50:46
问题 I want to be able to view the contents of my access database's laccdb file through VBA so I can use it to alert users (through a button) who else is in the database. I specifically don't want to use a 3rd Party tool . I have tried using: Set ts = fso.OpenTextFile(strFile, ForReading) strContents = ts.ReadAll This works fine if only 1 user is in the database. But for multiple users it gets confused by the presumably non-ASCII characters and goes into this kind of thing after one entry: Does

Generate random number VBA [closed]

余生颓废 提交于 2019-12-20 07:58:14
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I am trying to generate a random number and display it using a label. This is my code: Dim Random As Integer Random = Int((3 * Rnd) + 1) Label108.Caption = Random Why is my label not changing to a random number between 1 & 3 UPDATED AS PER QUESTION IN COMMENTS Private Sub Form_Load() Dim Random As Integer Random

SQL/VBA: How to group by a fiscal year starting from a day other than 1st day of month

那年仲夏 提交于 2019-12-20 07:52:34
问题 I’m trying (using MS Access) to group some data by a fiscal year, which can be different to the calendar year. If every fiscal year always started on the 1st of a given month, then the solution would be simple: one could simply use an if statement like this: FY: IIf(Month([orderdate])<month([startFYofaCompany]);Year([orderdate])-1;Year([orderdate])) in a select query like SELECT statement here AS FY, Sum(something) AS SumOfSth GROUP BY statement here; However, the difficulty in my case is

MS Access VBA SQL query debugging select case

半城伤御伤魂 提交于 2019-12-20 07:40:03
问题 In MS Access 2013 VBA I get a syntax error in this SQL-string: strSQL = "INSERT INTO [man_year] ( man_year_val, year_int, main_research_area, organisation, man_year_source ) SELECT KU.[2007], '2007' AS Expr1, " _ & "select case right(left(KU.man_year_source;6);2) like 'Hu' 3 case right(left(KU.man_year_source;6);2) like 'Sa' 1 case right(left(KU.man_year_source;6);2) like 'Te' 2 case right(left(KU.man_year_source;6);2) like 'Su' 4 case right(left(KU.man_year_source;6);2) like 'Ud' 5 AS Expr2,

Loop through records and increment value in vba access

别来无恙 提交于 2019-12-20 07:34:46
问题 I'm trying to loop through records in a table with part no's and with matching part no's, increment a value in the pos field. I asked a question earlier(Object variable or With block variable not set Access vba) with the same project but for a different step of the process (running a query). I haven't found a question that addresses this problem in Access yet, but I have taken some pointers from this question: Code to loop through all records in MS Access . Now, I'm trying to write the code