I have a networked database. It is accessed with computers that have both Office 2002, and office 2003. I get the following error message on computers with Office 2003:
"Object variable or With block variable not set"
It happens occasionally and the problem generally fixes itself so I dont think there is anything wrong with my coding.
And when it happens on the computers with office 2003 the ones with office 2002 can open the database fine.
Error 91 - Object variable or With block variable not set
I am getting this error telling me that an object variable is not set.
I know which variable it is but when I step through the debugger it sets the variable and all is fine? Issue is that public variable of a class is not getting set when the VBA Editor is not open?
This code runs fine the FIRST time, however trows up a message the SECOND time it is run.
The error is on the line ".Range"
I am trying to sort records which have been exported to Excel.
Dim LR As Integer LR = 5 Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True Set wbRef = xlApp.Workbooks.Add With wbRef
wbRef.Activate .Worksheets("Sheet1").Activate With ActiveSheet .Range("A2", .Cells(LR, "O").End(xlUp)).Sort Key1:=.Range("C2"), Order1:=xlAscending, Header:=xlYes End With end With
I have two reports running off of the same crosstab query. I copied one report to make the second report, then modified the second report to change the background of column fields satisfying certain conditions. These lines of code were added to the Detail_Format section, in color below. The report with the extra code lines does not error--the original report errors.
Code: Option Compare Database ' Constant for maximum number of columns EmployeeSales query would ' create plus 1 for a Totals column. Here, you have 9 employees. Const conTotalColumns = 11
[Code] .....
If I say OK (rather than debug) after the error message, I can then click the button for the report again and it runs without complaint. And, as I said, the report with the added code never errors.
The following block of code was working great until I came into work this morning. This routine is called from the OnClick event of several combo boxes. When it does, I recieve the error listed above (Object variable or With block variable not set) on line:
If Me.cbxAss_Filter <> "All" Then
Any ideas? I'm running on no sleep in the last 24 hours so I'm sure I'm missing something simple
The code itself checks the contents of a form and builds a string of conditions which I apply to the Form's filter property to filter records.
Code:Public Sub CreateFilter() '************************************************* **** 'Name: CreateFilter 'Purpose: Generate a string to filter the form 'Inputs: None 'Outputs: None 'Instigates: Me.Filter ' 'Updated: 11/30/06 'By: Chris Lounsbury '************************************************* **** 'Vars Dim strFilter Dim lngLength As Long strFilter = Null strFilter = "" 'Each filter box has its own check for contents If Me.cbxAss_Filter <> "All" Then strFilter = "assigned = '" & Me.cbxAss_Filter & "' AND " End If If Me.cbxAction_filter <> "All" Then strFilter = strFilter & "action = '" & Me.cbxAction_filter & "' AND " End If If Me.cbxStatus_filter <> "All" Then strFilter = strFilter & "status_rsrch = '" & Me.cbxStatus_filter & "' AND " End If If Me.Combo34 <> "All" Then strFilter = strFilter & "rims_flags = '" & Me.Combo34 & "' AND " End If If Me.cbxAAMB_filter <> "All" Then strFilter = strFilter & "aamb = '" & Me.cbxAAMB_filter & "' AND " End If 'Check if filter string was built If strFilter = "" Then Me.FilterOn = False Else 'Determine length of Filter String 'minus the trailing ' AND' lngLength = Len(strFilter) - 5 'Chop off ending ' AND' and set the form filter If lngLength <= 0 Then Else Me.Filter = Left(strFilter, lngLength) Me.FilterOn = True End If End If 'debug 'MsgBox (strFilter) End Sub
I need to export a table as a text file but using the outputto or transfer text options do not produce the file format I want. If I export the file as Excel and then save it as text it's OK so I copied the following code to automate the procedure but get an error 'Object variable or With block variable not set.
I get this error message, " object variable or with block variable not set", when I'm in the design view of a form wanting to use the command button wizard. Using a brand new database/blank I imported a table from my database in question. I then tried to make a new form and put a button on it. It worked for awhile but then when I close the database and reopen it to add another button to the same form, I get the error message again. It isn't a problem that is specific to my homeschool database. It affects all the database I use/maintain as well as any new "test" databases I've made trying to figure out this problem. I looked at references before and after the error occurs and there is not difference. I've also looked at code but don't see anything code that requires variables to be defined. In the case of the test database with one table and one form there is no code to look at until I make a button before exiting and even then, I don't see anything weird.
I would appreciate any help you can offer.
I've attached the original database I was working on when the problems began.
Is it possible for a database program to adjust security levels on certain reference libraries when installed on ones computer, thus making all other database act up that are using those libraries?
I have some code that will run if I am populating an empty table(no duplication's possible) but now I am trying to create a Sub to check for existence of a record and handling it going forward.
Anyways the big picture is looping through a text file and placing data where it needs to go. The code follows including some comments point to the issue.
Code: Sub PutinNewTag(TableIn As String, Tagtype As String, textline As String) Dim strSQL As String Dim NameIn As String Dim TagName As String Dim Db As DAO.Database Dim rstin As DAO.Recordset
I am creating a 2 level report to confirm an order. Main report already created, runs successfully called as subform/subreport under "OrderDetails" form. Linked to master using Order.ID. There are two versions of the confirmation report that have different layouts for different program types.
The hangup comes when I try to add a "Class Dates" subreport. It lists dates of individual classes and Skip dates. I have created the subreport as "srClassDates". When I add it to the main report, it lists the records. However, when I try to link it to the Main report, an error message box appears with the "object variable or With block variable not set".
I have tried rebuilding both the main and subreports, rebuilt the query, have not found anything that changes the result.
Linker has been working successfully on other subforms. Report with groupings works fine, but I need data from 2 tables both linked to order.id.
Private Sub Command167_Click() On Error GoTo Err_Command167_Click Dim objWordApp As Object Dim objWordDoc As Object Set oApp = CreateObject("Word.Application") 'make word not show up to user objWordApp.Visible = False Set objWordDoc = objWordApp.Documents.Open("C:Documents and SettingsUserDesktopEXPRESS DIPLOMA LETTER.doc") objWordDoc.PrintOut 'quits word objWordApp.Quit Set objWordDoc = Nothing Set objWordApp = Nothing Exit_Command167_Click: Exit Sub Err_Command167_Click: MsgBox Err.Description Resume Exit_Command167_Click
End Sub
When a command button is pressed, it returns: "OBJECT VARIABLE OR WITH vARIABLE NOT SET"
Does anyone have an idea on how to solve this problem?
I am just in the middle of writting a little bit of code that will go through each record in a query and export it into a word table. It's in the early stages but all was working yesterday. I've come to it this morning and ran it and now I get an error message;Run Time error 91: Object Variable or With Block Variable not set.
Code:
Private Sub Command15_Click() Dim MyDb As DAO.Database Dim rsLogin As DAO.Recordset Dim ObjHead As String Set MyDb = CurrentDb() Set rsLogin = MyDb.OpenRecordset("query here")
Once client details have been entered into frmclientdetails and the user has clicked cmdopenques, I would like frmhealthcheck to default to the client details entered. I've tried setting variables in VBA & using a queries/pop ups but can't seem to get this to work
I have created a Sales Report with Groupings of KeyID then CustID. I am not displaying Detail, CustID Header or Footer. In the KeyID Footer I need to display all CustID's that are included in the KeyID totals.
I have tried adding this code but get a error 2427. GroupFooter3 is the CustID footer.
Private Sub GroupFooter3_Format(Cancel As Integer, FormatCount As Integer) Let KeyGroup = KeyGroup & "," & Me.CustId End Sub
Private Sub Report_Open(Cancel As Integer) Dim KeyGroup As String Let KeyGroup = "Includes" End Sub
Also I have added a text box with the control =[KeyGroup] which doesn't seen to work.
I want to create a function module or something similar which will assign a variable to the max invoice # used on that table, using sql if possible. I tried something like this, but it's not working.
Public Function max()
Dim maxinvoice As String
maxinvoice = "SELECT Max(tbl_original.invoice) AS MaxOfinvoice" & _ "FROM tbl_original;"
MsgBox maxinvoice
End Function
I would like the msgbox to popup saying "5", since that is the max invoice # used based on the above table.
I don't have too much experience using modules on their own without forms and variables on the form to assign to, can someone make a suggestion?
In code i have built a string variable called strRAG which is a combination of text "Me!lbl" and another variable called intSiteID, which forms for example label name Me!lbl51.
I have a form with loads of labels on it and what i want to do is use this string to set the BackColor of the label.
The code i use loops round building up different label names but i am have problems relating the strRAG detail to the form labels.
I have posted this question in VBA early this week but after looking at the wording i have tried to rephrase it.
I'm trying to run an SQL statement to Sum the values of a table column. No problem. It would be useful for me to take that total and be able to set it equal to a variable within my VB code that's running, I just don't know how to do that, I'm very new to VB programming.
I cannot find help anywhere on the internet for this. :( I'd like to do something like this, just don't know how:
VariableName = Run.SQL ("Sum(tblName.Column) AS SumOfColumn FROM tblName")
I'm not a programmer by trade, so I am picking up things piece by piece, and just cannot find my way out of this task. Thanks for your help guys.
Hi there - on one of my forms i have a text box where the user can write the contents of a letter. When a button is pressed, a report is run, and the text from the form is entered into the report -
this all works fine - but when the text reaches a certain length, it goes all unreadable. SO i assume this use of a temp variable (as its not being stored in a table) comes with a text limit? Is there anyway to extend this?
I want to be able to reference a variable dependant on where I am within a loop. I have myct1, myct2 and myct3 looping then a mycount loop and I want to add a record to a table taking the relevant myct value dependanct on the current mycount value. Any ideas anyone?
I am using a query with a variable which select what records I want to use.
When I use the query from the query above it ask me for the variables again.
I do not want to input the variable again because I have the records I need but must use the 1st query for the secord query to build what I need.
How can I use the first query to build the 2nd query and not have to answer the variable input on the 2nd query? I already have the records needed.
Trust me, I need to build the 2nd query with the 1st query in order to do what I need to do. The first query select the dates I need, then the second query sums only the month and year and not the day of the month. However, I am asked for the dates again. I do not need for the user to put the dates in again. If you know how to do the operation all in one query, that would be great.
I created a query using a varible to select only the months needed. This variable will change based on the report needed next time. The customer has that option.
When I go to the report, I do not want to enter the variable again (Query has the correct records already), but the report is dependent upon the query.
How do I use the query for my report without entering the same variable again?
This is a very common situation, but I can not eliminate the dependence in the report.
For example: query1: I have a input, which is [Please enter the value 1:]
Then, I want to use this query, but different values. I want to put [Please enter the value 2:]
In SQL, how can I write?
Select [Please enter the value 1:] As v1, Please enter the value 2:] As v2 from combine Union Select * from query1 Union Select * from query1 where [Please enter the value 1:] = [Please enter the value 2:]