access-vba

Create a query dynamically through code in MSAccess 2003 [VBA]

こ雲淡風輕ζ 提交于 2019-12-18 05:39:02
问题 Hi I need to create a query in MSAccess 2003 through code (a.k.a. VB) -- how can I accomplish this? 回答1: A vague answer for a vague question :) strSQL="SELECT * FROM tblT WHERE ID =" & Forms!Form1!txtID Set qdf=CurrentDB.CreateQueryDef("NewQuery",strSQL) DoCmd.OpenQuery qdf.Name 回答2: Thanks for this answer and the small piece of code. If somebody needs to define the datatypes for the variables used, use this: Dim strsql As Variant Dim qdf As QueryDef 回答3: Dim strSql As String 'as already in

Create a query dynamically through code in MSAccess 2003 [VBA]

一曲冷凌霜 提交于 2019-12-18 05:38:31
问题 Hi I need to create a query in MSAccess 2003 through code (a.k.a. VB) -- how can I accomplish this? 回答1: A vague answer for a vague question :) strSQL="SELECT * FROM tblT WHERE ID =" & Forms!Form1!txtID Set qdf=CurrentDB.CreateQueryDef("NewQuery",strSQL) DoCmd.OpenQuery qdf.Name 回答2: Thanks for this answer and the small piece of code. If somebody needs to define the datatypes for the variables used, use this: Dim strsql As Variant Dim qdf As QueryDef 回答3: Dim strSql As String 'as already in

Create a query dynamically through code in MSAccess 2003 [VBA]

爷,独闯天下 提交于 2019-12-18 05:38:08
问题 Hi I need to create a query in MSAccess 2003 through code (a.k.a. VB) -- how can I accomplish this? 回答1: A vague answer for a vague question :) strSQL="SELECT * FROM tblT WHERE ID =" & Forms!Form1!txtID Set qdf=CurrentDB.CreateQueryDef("NewQuery",strSQL) DoCmd.OpenQuery qdf.Name 回答2: Thanks for this answer and the small piece of code. If somebody needs to define the datatypes for the variables used, use this: Dim strsql As Variant Dim qdf As QueryDef 回答3: Dim strSql As String 'as already in

Display multiple attachments in microsoft access 2010 forms and reports

折月煮酒 提交于 2019-12-18 05:15:13
问题 I was initially very pleased to discover the attachment field in Access 2010. It's a feature that aesthetically irks my inner database purist but my inner lazy sod is in charge here and it does look, on the face of it, like it could make one of my current projects much easier/simpler. Happily it displays pictures/icons automatically on the forms and reports but (why is there always a but eh!) it only displays the first one and I need it to display all of them. You can of course scroll through

Using MsgBox without pausing the application

别等时光非礼了梦想. 提交于 2019-12-18 03:58:05
问题 I need to display a message to the user. When I do this using MsgBox , the program stops until the user clicks the box away. I'd like to know if there's a way to open the MsgBox without pausing the program. 回答1: Sounds like you're not expecting any user input from the MsgBox. In this case, depending on your application, the StatusBar may be an adequate substitute. In Excel this is easy: Application.StatusBar = "Please be patient..." Application.StatusBar = iDone & " of " & iTotal & " items

Access VBA equivalent to a C# List<T>

不羁岁月 提交于 2019-12-18 03:45:36
问题 I have a COM-visible object written in C# that accepts a list of string arrays. Could I send a Collection of string arrays from Access 2000 to this object and it work? If not, then what is the best way to send multiple string arrays to my C# object from Access 2000? 回答1: You can't marshal generics but using Collection on the VB6 side is a workable solution. Effectively convert your List to a standard collection. Here's something that elaborates more: http://www.codeproject.com/KB/COM

How to create controls at run time Access VB?

限于喜欢 提交于 2019-12-18 02:57:54
问题 How can you create controls at run time with VB code in Microsoft Access? after some digging I found that this is possible with the CreateControl function. The problem is every random forum I find online has some code similar to this: Private Sub Button_Click() Call AddLabel End Sub Function AddLabel() Set ctl = CreateControl("MyForm", acLabel, acDetail, "", "", 0, 0, 100, 100) With ctl .name = "myTextBox" .Caption = "Hello World!" .Height = 50 .Width = 100 .FontSize = 11 .Visible = True End

How to Replace Multiple Characters in Access SQL?

蹲街弑〆低调 提交于 2019-12-17 21:18:28
问题 I'm a novice at SQL, so hopefully someone can spell this out for me. I tried following the "Replace Multiple Strings in SQL Query" posting, but I got stuck. I'm trying to do the same thing as the originator of the above posting but with a different table and different fields. Let's say that the following field " ShiptoPlant " in table " BTST " has three records (my table actually has thousands of records)... Table Name: BTST --------------- | ShiptoPlant | | ----------- | | Plant #1 | | Plant

Global Variables in SQL statement

倖福魔咒の 提交于 2019-12-17 20:55:54
问题 I have the following code in VBA: Dim strSQL As String strSQL = "UPDATE Workstations SET MID = newvalue WHERE MID = tempvalue" DoCmd.RunSQL strSQL newvalue and tempvalue are both global variables and have already been set values. Syntax wise, does this make sense? or am I missing quotation marks? 回答1: Try this one: If MID is number : Dim strSQL As String strSQL = "UPDATE Workstations SET [MID] = " & newvalue & " WHERE [MID] = " & tempvalue DoCmd.RunSQL strSQL If MID is string (if newvalue /

Is it possible to create a check constraint in access and/or DAO?

送分小仙女□ 提交于 2019-12-17 20:42:16
问题 I am trying to create a check constraint on an access (jet?) table. So, I open the .mdb file with access, go into queries->create query in design view, type esc, then menu->view->query and finally type create table X ( a number, check (a > 20) ) but access thinks that I have a "syntax error in field definition". However, I don't think so. Therefore my question: is it possible to create a check constraint with access. If so: how. Additionally, I'd like to create the constraint with dao/vba,