ms-access

Counting unique combinations

我与影子孤独终老i 提交于 2021-01-29 18:41:58
问题 I have a table in the following format: And I am trying to find a way to count different combinations of the categories. Here is the output I am looking for: I tried grouping the Category field, but I cannot figure out a way to create a unique combination. Screenshots are in excel, simply for illustration purposes. Actual data is in ms-access. 回答1: First get the unique pairs in a subquery and then join twice to the table to group and count: select t1.Category & '+' & t2.Category as Category,

Retrieving “Number” From Sql VB.NET System.Data.OleDb.OleDbException: 'Data type mismatch in criteria expression.'

♀尐吖头ヾ 提交于 2021-01-29 18:36:26
问题 If I want to retrieve a value that is saved as a number in an access database. Im using the following: Dim sql As String = "SELECT ArithmeticScore FROM " & tablename & " WHERE DateAscending = '" & todaysdate & "'" Using connection As New OleDbConnection(getconn) Using command As New OleDbCommand(sql, connection) connection.Open() scorevalue = CDec(command.ExecuteScalar()) 'Data type mismatch in criteria expression. connection.Close() End Using End Using MsgBox(scorevalue) getconn = connection

Finding OS short date format string in MS-Access/VBA

天大地大妈咪最大 提交于 2021-01-29 18:30:52
问题 I am looking for a VBA function that would return the current OS Short date format (ex: M/d/yyyy , dd-MMM-yy , yy/MM/dd , etc.) as a string. I have found such functions for MS Excel on related posts using Application.International , but they do not work with MS Access. I want to be able to show the OS date format in my forms to avoid confusion if '08-11-11' is displayed, for example. Using CDate() , my dates are automatically formatted to whatever is set in Windows Date and time settings.

Require that form fields are filled before saving a record

强颜欢笑 提交于 2021-01-29 18:30:39
问题 I have a form with fourteen fields, ten of which are always required, and three of which ( Other Absence Type , Illness Type and Other Illness Type ) are conditionally required. There is also a Save Record button on the form, which has a subroutine meant to check that all required fields are filled before saving the record. The ten required fields have their Required property set to Yes in the table. The code for enabling/disabling the three conditionally required fields appears to work on

How to suppress error message after cancel report print?

时光总嘲笑我的痴心妄想 提交于 2021-01-29 17:15:34
问题 I used DoCmd.RunCommand acCmdPrint to print a report. If I print the report, ok. But if I cancel, Access show a error and stop run the button code. I used DoCmd.SetWarnings (False) but don't suppress this error. How can I do? 回答1: You need to check the error code in your error handler, and if it's "Operation cancelled", ignore it. Option Explicit Sub Something() On Error GoTo Trap 'DoCmd... Leave: On Error GoTo 0 Exit Sub Trap: If Err.Number <> 2501 Then MsgBox Err.Description, vbCritical

Run Excel Macro from Access macro in VBA

陌路散爱 提交于 2021-01-29 17:09:20
问题 I am trying to run an excel macro from access 2016. This has a lot of examples out their however they are all old. The exact error code I receive is run-time error '1004': cannot run the macro "TestScript()". The macro may not be available in this workbook or all macros may be displayed. I am only running something easy for the test. I have ensured that macros is enabled in excel. the excel code is as follows Public Sub TestScript() MsgBox "IT WORKED" End Sub Real simple for the test. Access

How to transfer an excel spreadsheet to an access database

﹥>﹥吖頭↗ 提交于 2021-01-29 16:14:28
问题 I'm making a program to track my weight, calories I eat in a day, and the date, to help me lose weight. I'm manually putting in these values into a spreadsheet with those three columns (date, calories, weight). I want to transfer the information in these three columns into an access database. Code so far: Sub transferdata() Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset connStr = "C:\Users\sachu\Desktop\Assignment 5\CalorieDatabase.mdb" providerStr = "Microsoft.ACE.OLEDB.12.0"

MS-Access or Excel: Convert data from rows to columns, in unknown range of columns

非 Y 不嫁゛ 提交于 2021-01-29 14:58:05
问题 I have a table like this: **customer_id product_id** 1 1234 1 1125 1 6528 2 5645 2 5528 3 4565 And I want to make a query that will give the same information, where each consumer will have one row, and each product_id will be in a separate column, when I do not know how many columns are needed, because each consumer has made a different amount of purchases, This is the result I want: **customer_id First_product Second_product Third_product ** 1 1234 1125 6528 2 5645 5528 3 4565 Note this: How

Visual Basic .NET Access Database Record Add

和自甴很熟 提交于 2021-01-29 12:59:55
问题 I have problem with database save changes: coon1.ConnectionString = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _ "magazyn.mdb" sql = "INSERT INTO magazyn (ID_Towaru,Kod_Towaru,Nazwa_Towaru,Ilość_w_magazynie,ilość_minimalna,ALERT) VALUES ('" & jakiid & "','" & kodtowaru & "','" & nazwatowaru & "','" & iloscwmagazynie & "','" & iloscminimalna & "',0)" Dim MyConnection As New OleDbConnection(conn) Dim command1 As New OleDbCommand(sql, MyConnection) command1.Connection.Open() command1

Visual Basic .NET Access Database Record Add

孤街醉人 提交于 2021-01-29 12:15:50
问题 I have problem with database save changes: coon1.ConnectionString = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _ "magazyn.mdb" sql = "INSERT INTO magazyn (ID_Towaru,Kod_Towaru,Nazwa_Towaru,Ilość_w_magazynie,ilość_minimalna,ALERT) VALUES ('" & jakiid & "','" & kodtowaru & "','" & nazwatowaru & "','" & iloscwmagazynie & "','" & iloscminimalna & "',0)" Dim MyConnection As New OleDbConnection(conn) Dim command1 As New OleDbCommand(sql, MyConnection) command1.Connection.Open() command1