access-vba

Insert statement with where clause

Possible Duplicate: Query Syntax error I want insert value using the below command DoCmd.RunSQL = "insert into tblContract( Empid, Start1, Finish1, Store1, Start2, Finish2, Store2) values ('" & Me.txtEmpNo.Value & "','" & Me.txtContSunStart1.Value & "', '" & Me.txtContSunFinish1.Value & "','" & Me.txtContSunSto...

Query problem

When I execute this query: Dim Var Var = ("select max(Autonumber) from tblAutonumber") DoCmd.RunSQL (Var) I am getting the value of var as "select max(Autonumber) from tblAutonumber" instead of the maximum value I am looking for. Code: Private Sub btnSubmit_Enter() DoCmd.RunSQL ("insert into tblAutonumber (Dummy)values ('DummyValue'...

Query regarding dsn string in vba

Below is the code to fill a list box in a VBA application : Private Sub Form_Open(Cancel As Integer) ''#Populate list box control. Dim cnn As ADODB.Connection Dim strSQL As String Dim rst As ADODB.Recordset Dim strList As String On Error GoTo ErrHandler ''#Use DSN to Northwind. ''#Modify connection and connection str...

Proper Use of a Class Instance

I'm using Access 2003 VBA to process recursive data for manufacturing BOMs. I built a class module to let my main tables have static scope. This seems to simplify recursion -- it sets me free from counting levels down and up again as I traverse a BOM. I'm not opening the same recordset redundantly; I'm filtering a lot instead. Afte...

Dlookup problem null value

I have a problem with the below dlookup fuction its result Null value txtAbsSunStore1.Value = DLookup("Store1", "tblAbsense", "TestId = " & lstResults.Column(1, 0) & " And Day = 'Sunday' And Empid = " & Me.txtEmpIdSearch.Value & " ") All the variable have value and the corresponding value is there in the table too ...

Assigning number value to a variable in VBA

I need to assign a number value to a variable in VBA. I did this: var num as integer num=1 but when I put a breakpoint at num=1 and see the value of num it's showing 0 (zero). Please help. ...

MS Access 2003 - VBA for getting user name from LAN sign on

Is there a way to set up a function that will get the user name of the user's LAN sign on, to use for the =(getusername) within Access? Is there some general vb that will work for this idea? thanks! ...

First week date to be added in VBA

Hi , I need to add automatically current weeks first date into a table and a text box of a vba form. could anyone help if any functions are available ?? ...

"Null" value in Queries

I'm trying to run code that will copy fields into a new table, moving them from a _New table to the original table. The VBA code that does this works as such: SQLStatement = CStr("INSERT INTO " & TName & " SELECT * FROM " & TName & "_New") Log.WriteLine "Running query with string """ & SQLStatement & """ " QueryTimer = Timer DoCmd.RunS...

In C#, how do you convert the TimeSpan datatype to DateTime?

I'm converting a small MSAccess application to a web-based ASP.NET app, using C# 3.5. I was wondering what's the best way to work with dates in C#, when converting some of this VBA code over to C#. Here is an example of the VBA Code: Coverage1=IIf(IsNull([EffDate1]),0,IIf([CurrDate]<=[EndDate1],[CurrDate]-[EffDate1],[EndDate1]-[EffDat...

Access 2007 Emtpy Query Quirk

I have an Access 2007 DB in which I want to display a split-view form (half form, half datasheet) with a data source of a query. However, there is a chance that the query could be empty. In the event that the query has zero rows, none of the form controls are displayed. Is there any way to make sure all the form controls are displayed...

Visual Basic _ Question about findings the right study material?

Hey does anyone know of a great book/CD-ROM, etc for learn some novice to advanced Visual Basic study. I think I have about graduated the beginner stage. The main thing I need to do with Visual Basic is use it in conjunction with Office applications (2003 to be precise). Mostly MS Access, Excel and PowerPoint. But I want to learn more, I...

Access 2007 DAO VBA Error 3381 causes objects in calling methods to "break".

---AFTER FURTHER INVESTIGATION--- "tblABC" in the below example must be a linked table (to another Access database). If "tblABC" is in the same database as the code then the problem does not occur. Hi, We have recently upgraded to Office 2007. We have a method in which we have an open recordset (DAO). We then call another sub (Updati...

How can I switch an Access database between shared and exclusive mode?

I'm working on a program that needs to edit some objects in an Access database. It also runs a subprogram (long story) that tries to access the underlying JET database while Access still has it open via ODBC. The problem is that as soon as I start editing Form objects using VBA - for example, using Application.LoadFromText - Access cha...

Input Mask without Year for date

Could anyone help me in inserting a input mask formula for date in a access form textbox that shouldnot take year which only take date and month in the below format : DD/MM Not in DD/MM/YY Thanks for help in advance ...

Accessing Field2 in Access 2007

I'm trying to write a simple little routine to email an attachment stored in an Access 2007 database. For some reason I cannot get the simplest part of it to work. I get an error saying "User-defined type not defined" on the following line: Dim attachmentField As DAO.Field2 Now up to this point I haven't accessed any DAO objects yet,...

Strange field assignment issue in DAO with Access 2007

This is a follow-up on my previous question. Once I got the problem with the reference sorted out, I ran into another pretty strange issue. Basically, I have the following behind a button on a form: Dim attachmentField As DAO.Field2 attachmentField = Recordset("Att") I have now linked the reference, placed a break point on the secon...

MS access table as centralised location for storing data

Is it possible to make my MS access tables as a centralised location for storing data I have an mdb access file to store data into a table using a form. Is it possible to enter data to a centralised location? this mdb file copies are used by five user at same time Please help ! ...

Query after splitting access database

I have splitted my ms access mdb file into front end and backend Now i have the backend in the shared folder and frontends in users PC i havent specified the network path anywhere in the front end to push data to the backend file Could anyone tell me where i have to specify network path ??? ...

Validation in text box vba

i have vba textbox where i can take the validation which should only take number and accept UPTO 8 character length how can i put a validation which will take only this? ...