Compile error:Argument not optional
I am getting the above error while executing the following query:
DoCmd.RunSQL = "insert into tblContract (Empid,testid,Start1,Finish1,Store1,Start2,Finish2,Store2 )values ('" & Me.txtEmpNo.Value & "','" & Me.txtAutoNumber.Value & "','" & Me.txtContSunStart1.Value & "', '" & Me.txtContSunFinish1.Val...
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'...
I am copying an VBA code snippet from MSDN that shows me how to grab results from a SQL query into excel sheet (Excel 2007):
Sub GetDataFromADO()
'Declare variables'
Set objMyConn = New ADODB.Connection
Set objMyCmd = New ADODB.Command
Set objMyRecordset = New ADODB.Recordset
'Open Connection'
o...
I am doing a multiple insert in vba access query as below:
Private Sub btnSubmit_Enter()
DoCmd.RunSQL ("insert into tblAutonumber (Dummy)values ('DummyValue')")
Dim lastAutonumber As Long
lastAutonumber = DMax("Autonumber", "tblAutonumber")
txtAutoNumber.Value = lastAutonumber
DoCmd.RunSQL ("insert into tbltesting " & _
"(Empid, Te...
I am developing a vba form for employee database, in that there is a search criteria for userid and employees name with the userid should be displayed in a list box control which comes from a single table
I need to populate a list box with value from a table according to a value in a text box which act as a search box (eg: userid)
Plea...
I need to populate the access form list box from a access table.
Below is the code which I copy-pasted on button click event:
Public Sub PopulateLBWithData(DBPath As String, _
TableName As String, FieldName As String, _
oListControl As Object,Optional Distinct As Boolean = False, _
Optional OrderBy As String)
''#PURPOSE: Populate a l...
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...
Below query is resulting NO rows
lstResults.RowSource = "select EmpId from tblTesting where Empid ='" & Me.txtSearchEmpId.Value & "'"
Where below working fine :
lstResults.RowSource = "select * from tblTesting"
WHere is the fault here?
I check the value of '" & Me.txtSearchEmpId.Value & "'" using break point its having the value o...
I am planning to insert value in a vba access form text box values to the table in same access file
Here i will write a insert query on the submit button click event
Is there any shortcut methods to add the value into the table?
Like seting the datasource for the textbox and inserting values of all textbox in the form using a click o...
Hi,
Could anyone guide me in creating an Outlook Macro that does the following:
Whenever I send a mail to a particular mail-id an automated mail will be send to a specified group pa mail-ids or some outlook contacts group.
Thanks in advance!!
...
I'm trying to migrate a VBA macro to VSTO (Word). In the macro I did the following to insert an Autotext at the currently selected Position:
ActiveDocument.AttachedTemplate.AutoTextEntries("agenda#").Insert where:=Selection.Range, RichText:=True
Now I've added a rich-text-contentconrtol (XYZ) to the document, but I'm not able to find ...
I have multiple sets of code I need to run in Access 2007 and I have been trying to see if it would be acceptable to run them at the same time. Each set of data I need to have my Access VBA code run through takes about 5-8 hours to run. Would running them two at a time or all at once cause any problems?
They are each self contained and...
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...
I have made an Access 2007 db. I will be writing some basic vba for the appropriate event of a form so that a modal form is displayed when the original form is opened. This isn't difficult, but that form will have a drop down box of IDs from a particular table. The user will select an ID, but I want the selected ID from this form to go b...
I am working with Excel 2007 and the following suggestion from this site has not worked:
Workbooks.Open Filename:=ThisWorkbook.Path & "\Chapter 7 - 10 MECHANICAL.xls"
I have also tried the following code w/ no luck as well:
Workbooks.Open Filename:=app.Path & "Chapter 7 - 90 ECS 1 LLC.xls"
The files are in the same path as the work...
Hi, I am trying to create a macro that has a loop which copies a function down column 1 (VOL) and another function down column 2 (CAPACITY) for each Station. This is what I have so far:
Sub TieOut()
Dim i As Integer
Dim j As Integer
For i = 1 To 3
For j = 1 To 3
Worksheets("TieOut").Cells(i, j).Value = ...
Hi,
we have a COM add-in that we use in MS Office application like Word and Excel.
That COM add-in has exposed few APIs to use, which we use for customization.
Problem is - Any user can access the APIs and that is causing security problems.
we dont want that to happen, we want to give access to VBA editor to only few peoples.
Is there...
I found sometimes is really difficult to choose which one to use, e.g
I want to fill up the data to a list box, you can do it by select data and build a query for it, also you can build a VBA code and put it under the control event.
So, which one is better or we say, if we have choice which one is the best?
Thanks
...
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
...
I have the below query which will delete data from multiple tables
its not working
please help me :
DoCmd.RunSQL ("delete tblTesting,tblCodes,tblContract,tblScheduled,tblAbsense,tblClock from tblTesting,tblCodes,tblContract,tblScheduled,tblAbsense,tblClock where tblTesting.TestId = " & lstResults.Column(1) & " And tblTesting.Empid = ...