Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




ASP Application Variable


Can u assign an object to an application variable in global.asa. if so how ?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Open An Application And Send Value To The Application Variable...?
I use the following coding to call out another application from current application, but I don't know how to send some value to new opened application...?


Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long

Private Sub CmdOpen_Click()
On Error GoTo Err1:

Dim MyAppID, ReturnValue
ReturnValue = Shell("C:Program FilesMCSSMCSS.exe", 1)
AppActivate ReturnValue

End Sub

Copy SQL Variable To Vb Application Variable...
Is it possible to copy a SQL variable to a vb application variable without the use of a recordset?

Using a recordset:
...
qdfPassThrough.ReturnsRecords = False
qdfPassThrough.SQL = "SELECT @cnt := COUNT( * ) FROM some_table;"
qdfPassThrough.Execute
qdfPassThrough.ReturnsRecords = True
qdfPassThrough.SQL = "SELECT @cnt;"
Set rs = qdfPassThrough.OpenRecordset()
MsgBox rs(0)


Thanks in advance
Ed

What's An Application Variable?
It may be something real easy, and I have seen some post that talk about it, but I still don't know what it is... Please help.

Transmitt Variable To Another Application.
Hi there,

Suggest that I have 2 VB application, the first does somethings, returns a variable and then transmitt and call the second application. Can we do this if yes, please show me how to do.

Thanks in advanced.

Pass Variable Between Application
Is there any way to pass a variable out the program to another vb program?

Application Variable Expires?
I'm playing around with using Application Variables to contain XML data for my site's RSS Feeds. The feeds used to query the database directly every page load and some of the requests can pull a couple thousand records. Don't lecture me, that's how I found the site when I got the job.

My thought on optimizing page loads for these feeds was to load the data from the DB into an application variable. Overall, it's working pretty well but some things puzzle me:

Expiring Application Variables? Seems to me after 12 or 10 hours (haven't tested to be sure) the Application variable expires. I've got code that checks if the variable="" and if so hit the database and populate it again. That's not a problem, but I'd just like to know more what, exactly, is going on there.

Are Application Variables recommended for this? Or, is there a better method for doing what I want here? I haven't ever played with using a Cache object but read on here about how you've got some flexibility in how it expires. Any recommendations on that front?

Thank you!

Passing The Application Variable To A Class
I am writting an Addin that works with multiple Office programs but does the exact same thing in all of them. I want to simplify my code so I started to code a class file that would have all of the events that every program would use so I wouldn't have to retype it for each Office program. The problem is I have to get the Application variable I declare in the Designer file specific to the Office program, to pass to the new class file. Something like this:

wApp = word.Application

(I will have wApp, pApp for PowerPoint, xApp for Excel, etc...)

The wApp has to pass to the new class file so I can do things like this:

wApp.Documents.Count > 1

Can anyone help me?

Perserve Variable Value After Termination Of Application
Hello,
I want to save dynamic value(string) after termination of application [in VB-6], so I can use that value after I restart the application.

I am trying by REGISTRY link, can you pls provide me code for that.

lets say:


VB Code:
dim x as stringx="heaven" [runtime/dynamic value]


I want value of x after I re-load the application.

can you ples resolve my problem, it seems simple.
Thank you very much.

*RESOLVED* How To Put Path Of Application In A Variable?
This is probably a noob question, but i'm still new to vb so please excuse me.

I'm creating just a simple application with just one form with some buttons to open different excel files. My form is thus not much more than a gateway to different .xls files. The users clicks a button and the according .xls file needs to open. The problem is that the .exe file (which opens the form) can be anywhere on the users pc, so i need to know the path so i can make the link to the .xls files.
Does anyone know how i can put the path (of the program) into a variable? i've tried application.path but that just gives me the path to the office folder.
Thanks in advance!

Cheers,
Arie

Storing A String Variable In VB Application
Hi all,

Does anyone know of a way to store a string in a VB application, and being
able to change the value of that variable. Then next time when I run the
application again, it will remember the new value I have stored?

I figure I could use a 'Tag' but it doesn't remember what I have changed in
the last run. It always gives me the original tag value I entered.

Thanks in advance!

Tania

How To Send Object Variable To Another Application?
I have an object setup in an application using VBA and I would like to read that into a VB exe that I am setting up. Is this possible? I've found information on how to send/recieve text data, but what about passing objects?

ADO Connection Objecat As An Application Variable
Hi,

I am trying to write an intranet application which queries the SQL Server constantly. The webclass application I have written currently connects and disconnects from the database for each query which is proving to be costly for me. I am now trying to open the database connection in the global.asa and use that connection object to execute all the queries. But the problem I am facing is the object I have declared in the global.asa is not being passed inside successfully. I get a runtime error 3001.

Here is the code snippet of how I am making calls in the global.asa and also in the webclass

Global.asa
---------------------------
'Initialize Database Connection with ADO RecordSet
Set DBConn = Server.CreateObject("ADODB.Connection")
'Establish the Connection
DBConn.Open "DSN=" + SQLSource + ";SERVER=" + SQLServer + ";UID=" + SQLAccount + ";PWD=" + SQLPassword + ";DATABASE=" + SQLDatabase
'Define Connection Object
Set Application("DBConn") = DBConn



Inside my webclass
---------------------------------
Dim objDBC As ADODB.Connection

Set objDBC = Application("DBConn")
If (XConnect(objDBC)) Then MsgBox "Gr8"

Function XConnect()
------------------------------------------
Function XConnect(DBC As ADODB.Connection) As Boolean
Dim Cmd As New ADODB.Command
Dim Rs As New ADODB.Recordset

XConnect = False

'Define the connection to be used
Set Cmd.ActiveConnection = DBC
'******************************************************************************
GETTING ERROR WHEN I EXECUTE THE ABOVE STATEMENT

Run-time error '3001':

The application is using argument that are of the wrong type, are out of
acceptable reange, or in conflict with one another.
'******************************************************************************


'Define the SQL to be executed
Cmd.CommandText = SQL0 'Simple sql statement returning 1 row 1 columen
'Open the Recordset
Rs.Open Cmd, , adOpenStatic, adLockBatchOptimistic
'Get the Number of Rows returned
If (Rs.RecordCount > 0) Then XConnect = True
End Function

Shell.Application Code From Variable Cells.
I'm having problems with a Workbook I've been creating in Excel.

I need to be able to select a user from a ListBox, click "View Files" and be taken to the user's My Documents on the network. All the usernames are stored in "Data!J3:J50" and the concatenated pathnames to launch are in "Data!M3:M50"


Code:
Private Sub FileURL_Change()

'This is a textbox to show the path I'm trying to get to, to the end user.

End Sub

Private Sub NameList_Click()

'This is the list of names.
' Values set via properties as "Data!J3:J50"

Dim FolderToView As String
FolderToView = "??????" 'This is where I'm not sure of the code.

FileURL.Value = FolderToView

End Sub

Private Sub ViewFilesButton_Click()

Set wShell = CreateObject("Shell.Application")

wShell.Open FileURL.Value

End Sub

I can get the TextBox to display the Value of the ListBox selection but I need it to display the respective information for the pathname of the user.

Basically I need to select "Doe, John" (Cell Data!J3) from the ListBox, it display "\server2usersAA1234" (The concatenated pathname in cell Data!M3) and then when you click the CommandButton the pathname opens in a new window (This much I can do with a static pathname, but not a variable one like I need.)

Any Ideas?

Updating Value Stored In Variable At Client Into Server Application
Dear All,

Please help if any body can suggest to the following problem.

I have a client server application developed in Vb 6.0. I want to store a value in variable at the client and would like to display the same in the server dynamically.

If any body got solution please help

Thanks


Rajnish

Updating Value Stored In Variable At Client Into Server Application
Dear All,

Please help if any body can suggest to the following problem.

I have a client server application developed in Vb 6.0. I want to store a value in variable at the client and would like to display the same in the server dynamically.

If any body got solution please help

Thanks


Rajnish

Global Variable Doesn't Change Because Of Application.OnTime?
i have a sub and a global boolean variable CallNext. if CallNext is true then the sub checkstatus is going to call itself again with Application.OnTime in a.e. 2 secs.
i have a form that calls the sub checkstatus in it's UserForm_Initialize and set CallNext into true. If the Button Cancel is clicked then CallNext is set into false.

But somehow the sub callnext still runs and calls itself. I found out later that the variable CallNext still has the value true, although i set it into false before.

Here is some of the code :
Form :

Code:
Private Sub CommandButton1_Click()
CallNext = False
Unload Me
End Sub

Private Sub UserForm_Initialize()
....
CallNext = True
Application.OnTime Now + TimeValue("00:00:02"), "ClientMonitor.checkstatus"
End Sub

Modul ClientMonitor :

Code:
Public CallNext As Boolean

...

Public Sub checkstatus()

...

If CallNext Then
Application.OnTime Now + TimeValue("00:00:02"), "ClientMonitor.checkstatus"
End If

End Sub

I set CallNext into true only in UserForm_Initialize and nowhere else...

any idea?

Thx

How To Assign A Cell/Range Address In A Variant Type Variable To Another Variable
Sir,


I have the following piece of code which looks up a certain date in several wrksheets and aims to return the value in a cell located in the next two columns (same row) where my look up value is.

For i = 1 To 23
    Worksheets(strFilename(i)).Activate
    Range("C4").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.NumberFormat = "[$-409]dd-mmm-yy;@"
    

Dim strFilename(1 To 23) As String, strFilename2(1 To 23) As String, strPath As String
Dim dtActProg As Date
Dim rngSearch As Variant
Dim c As Variant, c1 As Variant

    Set rngSearch = ActiveCell.CurrentRegion
    
       
       
    With Worksheets(strFilename(i)).Range(rngSearch.Address)
        Set c = .Find(dtActProg, LookIn:=xlFormulas)
        If Not c Is Nothing Then
            
            Sheets("Sheet1").Select
            Cells(i, 2) = c.Value

' Returns the date I enter via an Inputbox in the privous section of my code

' In the remaining section of my code I need to assign the address of the cell located in the 2nd column next to where code looks up date value assing it to a variable and return the value on Sheet1 next to where code writes c.vale

For example if c.address="$A$2" then c1.address must ve "$A$4 which will be listed on Sheet1 together with my dates entered via ListBox


                End If
   End With
Next i

Thanks,

Fatih Can
Petroleum Eng., MSc.

91:Object Variable Or With Block Variable Not Set(MDI Form Close Error)
When i close the password form above the MDI form,then i click the menu "password" again to enable it to open the password form again,but it pop up the error,"91:Object variable or With block variable not set".Here is my coding.Anyone can let me know where is my error?


VB Code:
Private Sub mnuChange_Click() On Error GoTo exithandler     Call Unload(ActiveForm)    Call Load(frmPwd)    frmPwd.Show    exithandler:         If Err Then        Call MsgBox(Err.Number & " : " & Err.Description)        Err.Clear    End If

Comment Je Peux Changer Une Variable String En Variable Object
comment je peux changer une variable string en variable object
dim f as string
f="Form1"
f->object comment??

Run Time Error 91 - Object Variable Or With Block Variable Not Set
Hi,

when I run my .exe I have this run time error 91 Object variable or with block variable not set ... i'm using a VB6 and this code was inseide in Module, the two function Criar_arquivo and TextoFixo was called inside of command button....

==================================
module
=====================================
Global word1 As Object
Function Criar_arquivo() As Integer

Dim word1 As Object
Set word1 = GetObject("", "word.application.8")
Set word1 = CreateObject("Word.Application.8")
word1.Documents.Add

End Function

Function TextoFixo() As Integer

With word1.Selection <---------------- error
.TypeText (Frame1.Caption)
.TypeParagraph
.HomeKey Unit = wdLine, Extend = wdExtend
With word1.Selection.Font
.Name = "Times New Roman"
.Size = 14
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.Strikethrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = True
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
End With

word1.Visible = True

With word1.Selection
.TypeText (Text1.Text)
.TypeParagraph
.HomeKey Unit = wdLine, Extend = wdExtend
With word1.Selection.Font
.Name = "Times New Roman"
.Size = 14
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.Strikethrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
End With
word1.Visible = True

End Function
==========================================

==================================
button
=====================================
Private Sub Command4_Click()


If Frame10.Enabled = True Then
Command4.Enabled = True

Criar_arquivo
TextoFixo
.
.
.
.
.
end sub



thanks

Rick

Runtime Error 91 Object Variable Or With Block Variable Not Set
Hi,

when I run my .exe I have this run time error 91 Object variable or with block variable not set when I create my textfile

_---------------------------------------------------_
Dim objFSO As FileSystemObject
Dim objTextFile As TextStream
Dim strFileName As String
Dim strRead As String

Public Sub WriteToFile()

strFileName = "C: ext.txt"
Set objTextFile = objFSO.CreateTextFile(strFileName,True)<---------------------------------rutime error 91
objTextFile.WriteLine ("I am writing to the text to the file.")
objTextFile.WriteLine ("")
objTextFile.WriteLine ("I am writing to the text to the file.")

End Sub
_----------------------------------------------------_

thanks

David

Run-time Error '91': Object Variable Or With Block Variable Not Set
Hello,

One of our users has a particular problem wit MS Excel. When she has a standard worksheet opened and want to close excel, a box with the typically VB questions "End" or "Debug" appeares. When the user clicks on End the message "Run-time error '91': Object variable or With block variable not set" appeares.

What could there be wrong? Can I resolve this bij resetting the users profile or is it caused by the specified excelsheet?

THX in advance!

Stoffel

Runtime Error 91. Object Variable Or With Block Variable Not Set
This error message is fast becoming the bane of my life! More irritatingly, I've no idea what it actually means, either. Can someone explain (in laymans terms, please ) what sort of thing causes it?

In the instant case, I'm just trying to read an access DB; I need to get a patient's last appointment from it to show up on a screen before the new one is entered. I'm getting the 91 error when I try and move to the last record in the recordset.

I'm referrencing an ADODC that (as far as I can see) looks correctly set up. I am doing so, however, in the form_load() routine, and one thing that occured to me was that maybe the ADODC doesn't "come into existence" until the form has actually been drawn? If this is the case, I can understand why it wouldn't work, as there'd be no connection yet between the program and the DB.

The complete routine is:





Code:
Sub Form_Load()

'First up, add units 1-10 into both the admin and treatment combi box
Dim AddUnits As Integer
For AddUnits = 1 To 10 Step 1
cmbTrtUnits.AddItem AddUnits%
cmbAdminUnits.AddItem AddUnits%
Next

' Now add the Day/Night options in
cmbDayNight.AddItem "D"
cmbDayNight.AddItem "N"

'And the workshop/clinc
cmbClinWShop.AddItem "W"
cmbClinWShop.AddItem "C"

'And finally, pull the OTs from the parmfile.
Dim conParmfile As ADODB.Connection
Dim dtaParmfile As ADODB.Recordset
Set conParmfile = New ADODB.Connection
conParmfile.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databasesparmfile.mdb;"
'conParmfile.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databasesparmfile.mdb;"
conParmfile.Open
Dim RecordType As Long
RecordType = 20
Set dtaParmfile = conParmfile.Execute("SELECT * FROM parmfile WHERE recordtype = " & RecordType)
dtaParmfile.MoveFirst

' Loop from the start of the file through to EOF and add the names provided
' into the OT combibox.
Do Until dtaParmfile.EOF
cmbAttendingOT.AddItem (dtaParmfile.Fields.Item("Data").Value)
dtaParmfile.MoveNext
Loop

' The next type of records to load into the combi-box are the treatment.
RecordType = 30
Set dtaParmfile = conParmfile.Execute("SELECT * FROM parmfile WHERE recordtype = " & RecordType)
dtaParmfile.MoveFirst

' Loop from the start of the file through to EOF and add the treatments
' provided in the parmfile into the treatment combibox.
Do Until dtaParmfile.EOF
cmbTreatment.AddItem (dtaParmfile.Fields.Item("Data").Value)
dtaParmfile.MoveNext
Loop

' ...and close the Parmfile off.
conParmfile.Close

' put the name, OT number and NHS numbers into the label fields
lblNHSNumber = frmAddress.txtField(9).Text
lblName = frmAddress.txtField(1).Text & " " & frmAddress.txtField(0).Text
lblOTN.Caption = frmAddress.txtField(24).Text

' Disable the Confirm Buttton
cmdConfirm.Enabled = False

' And hide the new appt text boxes
showNewApptFields False

With Adodc1.Recordset
.MoveLast (<- this is the line it highlights when it falls over)
Do Until lblOTN.Caption = .Fields(1).Value Or .BOF
.MovePrevious
Loop

If .BOF = True Then
MsgBox ("There is no previous appointment on record for this patient")
Exit Sub
End If

lblOldDate = .Fields(2).Value
lblOldAdminUnits = .Fields(4).Value
lblOldTrtUnits = .Fields(3).Value
lblOldDayNight = .Fields(5).Value
lblOldTreatment = .Fields(6).Value
lblOldClinWShop = .Fields(7).Value
lblOldAttendingOT = .Fields(8).Value
End With

' Preparations for adding in the new record are done, exit sub.

End Sub

What's really bugging me is that it worked fine before; I changed a couple of bits (not these bits, however!), and now it doesn't!

Any help will be very, very gratefully received!

Help With This Error: Object Variable Orwith Block Variable Not Set
it says, object variable or with block variable not set

i'm working here for an update to a mother table and child table

here's my code:



Code:
Private Function CalcUpdate()

Dim sUpdSql As String
`
sUpdSql = "UPDATE tblPayrollInfo SET SalaryLoan = Text1(0).Text,PolicyLoan=PolicyLoan = Text1(3).Text," _
& "Premium = Text1(6).Text, SalaryLoan_Pay = Text1(19).Text, PolicyLoan_Pay = Text1(20).Text," _
& "SalPayableIn =Text1(1).Text, PolPayableIn = Text1(4).Text, PrePayableIn = Text1(7).Text," _
& "IRateSal = Text1(2).Text, IRatePol = Text1(5).Text, IRatePre = Text1(8).Text," _
& "PhilHealthMed = Text1(9).Text, GSIS =- Text1(10).Text,OptionalPrem = Text1(11).Text, ODed1 = Text1(12).Text," _
& "ODed2 = Text1(13).Text, ODed3= Text1(14).Text, Desc1= Text2(0).Text,Desc2 = Text2(1).Text," _
& "Desc3=Text2(2).Text,Tax = Text1.Text, RATA = Text1(16).Text, ACA = Text1(17).Text, PERA = Text1(18).Text," _
& "Allowance =Text1(22).Text, GrossPay = Text1(23).Text, Deduction=Text1(24).Text, NetIncome=Text1(25).Text WHERE EmpInfo = " & cboEmpId.Text & " "

End Function




Code:
With adoEmp
.MoveLast
.AddNew
CalcUpdate
End With

adoEmp.Requery
please help out. tnx. it's really important

Run-time Error 91. Object Variable Or With Block Variable Not Set
Hi everybody,
The title of this message is nithing but the error message am having anytime I run my apllications on another computer.I mean different from the the one on which I developed it with.the applications are databse oriented and I do connect either using ODBC driver or OLE Jet 4.0.all the applications run perfectly on my system but I couldn't run them on other systems.where do you think the problem is (my system or the others) and what precisely can it be?thanks for your Removed By Mod

Runtime Error 91 Object Variable Or With Block Variable Not Set
Hi all,

I need help on this badly,
As title i run into this error (Runtime error 91 Object variable or With Block variable not set) after I package my program and install it on my local computer(WinXP SP2).
I ensure all my objects had been set and option explicit declare on every page of the code as from what I search from this forum.
But this error only came when I wanted to execute the program after installation.
I got no idea where to track the code where throws the error but during compiling all are fine.

Many Thks.

Run-time Error '91': Object Variable Or With Block Variable Not Set
Hi,

I developed a small sized application with database using VB 6.0 Enterprise SP-5 on a Win XP Pro box. The application runs just fine on this box. Later I created an installer using Inno-setup and got it installed on Win ME, I got above mentioned error when I open a form that was created using "Data Form Wizard" having connected to database using DSN and connection method being ADO-Control.

As per my investigation, the problem is that the application expects me to declare the "datPrimaryRS" which is the name of the ADODC control given by the wizard. Now I have no idea how can I declare an activex control?

I will appreciate if anybody can help me out on this issue.

PJ

Object Variable Or With Block Variable Not Set (image To Mysql)
I am trying to add an image to MySQL (Blob field) and I am getting a Object variable or with block variable not set error. Also, how would I retrieve the image from the database and load it into a picturebox?

VB Code:
If Not pbUserPicture.Picture = 0 And Not txtUsername = vbNullString Then        'save image to database        With m_ADOStream            [hl].Type = adTypeBinary[/hl]            .Open            .LoadFromFile pbUserPicture.Tag            Debug.Print pbUserPicture.Tag            m_ADORs!UserPicture = .Read                    .Close        End With    End If

Run Time Error 91 Object Variable Or With Block Variable Not Set
i have one form that creates a sql statement, and loads the results form, that uses the sql statement to search and display results.

the sql statement variable is defined in the first form as a public variable and the second form access it in my code like this:


VB Code:
with form1       ...findfirst .sqlvariableend with


but when it runs it comes up with the error in the title of this post??

can anyone see the problem???

GTJ

Run-Time Error 91 : Object Variable Or With Block Variable Not Set
Hi,
I've compiled an executable file which runs perfectly fine on the computer i initially created the program on but once i attempt to run the .exe on another computer there is no data in the datagrid and also when i attempt to scroll through the records i receive the error "Run-Time Error 91 : object variable or With block variable not set." Any ideas what the problem might be and how to solve it, much appreciated.
Thanks.

Run Time Error 91: Object Variable Or With Block Variable Not Set
I am trying to run this code and received the said error message on the second loop of the program on this specific line:

" ActiveWorkbook.SaveAs FileName:=Left(ActiveWorkbook.FullName, 20) & ".csv", FileFormat:=xlCSV, CreateBackup:=False "

circumstances: I am converting a multiple selected .xls file which i have chosen in a filelistbox into a .csv format
------------------------------------------------------------------------------------

Dim Exceltemp As Excel.Application
Dim I As Integer

Private Sub CmdConvert_Click()

For I = 0 To File1.ListCount - 1
MsgBox File1.List(I)
sChar = ""
If File1.Selected(I) Then
Set Exceltemp = New Excel.Application
If Right(Dir1.Path, 1) = "" Then
Exceltemp.Workbooks.Open File1.Path & File1.List(I)
Exceltemp.Visible = True
Set Exceltemp = Nothing
Else
Exceltemp.Workbooks.Open File1.Path & "" & File1.List(I)
Exceltemp.Visible = True
Set Exceltemp = Nothing
End If
frmConversion.Status1.Panels(1).Text = "Converting file into .CSV format...."
ActiveWorkbook.SaveAs FileName:=Left(ActiveWorkbook.FullName, 20) & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
End If
Next
frmConversion.Status1.Panels(1).Text = "Excel File converted into .CSV format..."
End Sub


Thanks a lot

Speed Issues With Global Variable Vs. Local Variable
I have a global integer variable that is assigned a number towards the beginning of the program. Farther on in the program I have a subroutine that will be accessing this value repeatedly throughout the procedure. My question is, should I: A) call the global variable each time I need to access that value; or B) create a local variable at the beginning of the subroutine in question, fill the local variable with the contents of the global one, and then just refer to the local variable each time I need to access that value in the subroutine? I'm wondering mainly if there will be any performance/speed issues between the two options.

Thanks!

Object Variable Ot With Block Variable Not Set (run-time Error 91)
What is wrong with the following code? The debugger gives an error at the blue line.

Sub dateadj()

Dim x As Integer
Dim a As Date

For x = 1 To 429
Worksheets("sheet5").Select
Cells(1222 + x, 6).Select
a = Cells(1222 + x, 6).Value
Selection.Copy
Worksheets("aangepast").Select
Cells(1 + x, 1).Select
ActiveSheet.Paste


Worksheets("sheet5").Select
Columns("A:A").Select


Selection.Find(What:=a, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate


ActiveCell.Offset(0, 1).Select
ActiveCell.Offset(0, 1).Copy
Worksheets("aangepast").Select
Cells(1 + x, 2).Select
ActiveSheet.Paste

Next x


End Sub

Run-time Error 91 Object Variable Or With Block Variable Not Set
Hi all,

I'm getting the following error message when I tried to use stored procedure in VB.6. Can anyone help me?

Run-time error 91 object variable or with block variable not set


Here is my code:

Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Dim strconn As String
Dim MyID As Integer

Private Sub Form_Load()

strconn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ma;Password=p2008;Initial Catalog=T_DB;Data Source=NSERVERDEV"
con.Open strconn
conn_info
End Sub

Private Sub conn_info()
MyID = InputBox("Enter a Report ID")
Set cmd = New ADODB.Command
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "Update_Job_Status"

cmd.Parameters.Append cmd.CreateParameter("JobID", adNumeric, adParamInput, 5, MyID)
Set rs = cmd.Execute

If Not rs.EOF Then
lblId.Caption = rs.Fields(0)
lblRun.Caption = rs.Fields(20)
End If

Set cmd.ActiveConnection = Nothing

End Sub

Thanks,
A
 

Difference Between Global Variable And Public Variable Is BAS Module
What is the difference between a Global Variable declared and a public varibale declared in BAS Module

for example in a BAS Module MyModule I am declaring the two varibles as follows

Public MyPublicName    as String
Global MyGlobalName    as String

Now i can use both the variable through out the project.

If so what is the difference between these two variables.

 

URGENT!!!! Error 91- Object Variable Or With Block Variable Not Set
Hi ppl.

This is an URGENT request. I made a program involving some ADODC and the .exe worked pretty fine in my computer (VB6, WinME), but when I copied it into a WinXP w/o VB computer, it asked me for some dll's and ocx. So I downloaded them and... The program ran, but NO RECORDS ARE SHOWN!!!! As if there is no link to the DB. Also, when I try to push any CmndBtn, the

Error 91 - Object variable or With block variable not set

is shown, and the program closes.

I suppose both problems are linked AND have to do with the ADODC, but I've no idea what to do. The program has no apparent errors (although I know it can be simplified) and the Err91 Msgbox appeared only when trying to execute the compiled file.

Any suggestions appreciated FAST!
PD.- The code is somewhat extense. If u need it to be shown, pls specify the part you want.

Thanks in advance,

UVMVB

Run Time Erro - 91 Object Variable Or With Block Variable Not Set
I created a setup.exe of vb 6.0 thro PDW. It was created succesfully. I downloaded the set up on a pc whicj do not have VB and installed it and tried to access the screen thro menu it says type mismatch.
run time error 91. object variable or with block variable not set.

anyone with some ideas why this err?. pls hlp me. it's urgent

hi JeffB

As you said I think there is no such reason b'cos when I compiled the EXe , ran the setup file in the development environment this err was not generated. This came into picture only when I ran the setup on a different PC. If at all this is the cause of the err then it should have given me this err in the devl. environment itself. What do you say? & above all I'm just calling a form through MDI form & here it generates this err

this is my third post. Plz anyone of you help me out

Object Variable Or With Block Variable Not Set (Error 91)
Private sub form_load
'yada-yada
cborecent_click
end sub

Private Sub cboRecent_click()
If InStr(1, cboRecent.Text, "-") Then
strFindID = Left(cboRecent.Text, InStr(1, cboRecent.Text, "-") - 1)
ElseIf InStr(1, cboRecent.List(0), "-") Then
strFindID = Left(cboRecent.List(0), InStr(1, cboRecent.List(0), "-") - 1)
Else
strFindID = ""
End If
cmdFindID_click
End Sub

Private Sub cmdFindID_click()
Dim cnt As Integer
Dim swapstring As String
Dim swapindex As Integer
If strFindID = "" Then
strFindID = InputBox("Please enter the Request ID to locate.")
bkmk = rs.Bookmark
Else
swapstring = "GO"
End If
'Debug.Print strFindID **** strFindID is set correctly
'Exit Sub
Data1.Recordset.FindFirst "[Request_ID] like " & Chr(34) & strFindID & "-*" & Chr(34)
this is where it blows up with data1.recordset.findfirst.
If I remove the cboRecent_click from Load_form above everything
works as it should even data1.recordset.findfirst. Can I not execute this from Load_Form? How should I approach this?

[HELP]Error 91: Object Variable Or With Block Variable Not Set
hello to all its nice to meet yah guys!

can any pls help me about this code i tried to create an login that check the username and password in the the access database and if the user exist then the user will able to enter into the system.

everytime i run the system it give me an error of

Error 91: Object variable or With block variable not set


my database name was momsdb.mdf and it is inside folder "database"

this inside my module file

Code:
Public rs As New ADODB.Recordset
Public con As ADODB.Connection

Public Function connect()
On Error GoTo err
Set con = New ADODB.Connection
con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "databasemomsdb.mdb;Persist Security Info=False"
con.Open
Exit Function
err:
MsgBox err.Description
End Function
my login form.


Code:
Public LogSuccess As Boolean

Private Sub cmdCancel_Click()
If MsgBox("Are you sure you want to quit the System?", vbYesNo) = vbYes Then End
LogSuccess = False
End Sub

Private Sub cmdClear_Click()
clear
txtUserName.SetFocus
End Sub

Private Sub cmdOK_Click()
On Error GoTo err
If txtUserName.Text = "" Then
MsgBox "Invalid Username!"
ElseIf txtPassword.Text = "" Then
MsgBox "Invalid Password!"
ElseIf txtUserName.Text = "" And txtPassword.Text = "" Then
MsgBox "Please don't leave field blank."
Else
LogSuccess = False
SQL = "SELECT * FROM tbllogin"
Set rs = con.Execute(SQL)
If rs.BOF = False Then
While Not rs.EOF
If txtUserName.Text = rs(0) And txtPassword.Text = rs(1) Then
username = rs(0)
LogSuccess = True

End If
rs.MoveNext
Wend
End If

If LogSuccess = True Then
Unload Me
Else
MsgBox ("Invalid username, try again!")
End If
err:
MsgBox err.Description & " " & err.Number
End If
End Sub

Private Function clear()
txtUserName.Text = ""
txtPassword.Text = ""
End Function

How To Use Outputs Variable As An Input Variable For Further Simulation?
Hello Dear Friends

I have this code in the form

.Inputs.Add "Input13", "RISKPert(Outputs(4), Outputs(9),0.023)"

and this code in class module

.Outputs(4) = 1 / .Inputs(9)
.Outputs(9) = 1 - .Inputs(12)

I want to use outputs 4 and 9 in my input 13. when I write the code in the above form the simulation doesn't run. It gave an error warning of invalid string.
The question is how can I put outputs 4 and 5 as a variable in input 13 and run the simulation? any help is appreciated
regards,
biruk

Error 91 Object Variable Or With Block Variable Not Set
Error 91 : object variable or with block variable not set

I only get this error at runtime when the application is compiled. But i cannot duplicate nor find this error anywhere when debugging in the development environment.

Error 91: Object Variable Or With Block Variable Not Set
Can anyone see what causes Error 91: Object variable or With block variable not set
I should add that this only happens when I have the bit of code that I have marked


Code:
Private Sub Form_Load()
Me.Visible = False
Dim x As Integer
Dim y As Integer
Dim rc As RECT
Dim ABD As APPBARDATA
Dim hWndAppBar As Long
ABD.cbSize = Len(ABD)
state = SHAppBarMessage(ABM_GETSTATE, ABD)
For position = ABE_LEFT To ABE_BOTTOM
ABD.uEdge = position
hWndAppBar = SHAppBarMessage(ABM_GETAUTOHIDEBAR, ABD)
If hWndAppBar > 0 Then
Select Case position
Case ABE_LEFT: position = 1
Case ABE_TOP: position = 2
Case ABE_RIGHT: position = 3
Case ABE_BOTTOM: position = 4
End Select
End If
Next

MakeWindowNotTop Me.hwnd
SHAppBarMessage ABM_GETTASKBARPOS, ABD
h = ABD.rc.Bottom - ABD.rc.Top
tb = ABD.rc.Bottom - ABD.rc.Top
h = h * 15
If position <> 4 And state <> 2 Then
h = 0
End If
x = Screen.Width
y = Screen.Height

Dim myProcesses As Integer
Dim proc As PROCESSENTRY32
Dim snap As Long
Dim exename As String
Dim shift_over As Integer
snap = CreateToolhelpSnapshot(TH32CS_SNAPall, 0)
proc.dwSize = Len(proc)
processLoop = ProcessFirst(snap, proc)
While processLoop <> 0
exename = proc.szExeFile
If InStr(exename, "desktalker.exe") Then
myProcesses = myProcesses + 1
End If
processLoop = ProcessNext(snap, proc)
Wend

shift_over = myProcesses * 3500
'from here
If shift_over > x Then
MsgBox "You have too many Desktalkers installed for your screen " & _
"width to accomodate. You may increase the number of " & _
"Desktalkers that can open by increasing your screen resolution. " & _
"Consult a technician for details and assistance.", _
vbInformation, "Demo Name"
End
End If
'to here. If this is taken out then no error
CloseHandle snap


frmMain.Left = (x - 3495) - (shift_over - 3500)
frmMain.Top = (y - 1050) - h
If IsConnectedToInternet() = False Then
tmrGetChunk.Enabled = False
WebBrowser1.Offline = True
Else:
WebBrowser1.Navigate "website address"
End If
new_state = state
new_position = position
new_tb = tb
Me.Visible = True
End Sub
Thanks
Robert

Object Variable Or With Block Variable Not Set (Error 91)
Hi all, can someone help me please.

I'm using Visual Basic for first time, and I try to set up a Macro in Excel:




Sub Name()
'
' Name Macro
' This Macro is searching for a Enquires Name
'

'
Sheets("Bookings").Select
Range("G24").Select

var1 = InputBox("Please enter the Family Name:", "Enguiries Name")

Range("A24:I50").Sort Key1:=Range("G25"), Order1:=xlAscending, Header:= xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal


If Cells.Find(What:=var1, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase :=False, SearchFormat:=False).Activate Then
MsgBox "Enquiries Name was found", vbDefaultButton1, "Success..."

ElseIf var1 <> "" Then
MsgBox "Enquiries Name was not found", vbCritical, "Try Again..."

End If
End Sub

Each time, when I run it. It is working, if I put a value in, that is in my sheet. But when I try to put something, that is not there. I have not my ElseIf value but an.................................................................... .. Object variable or With block variable not set (Error 91)

I have no Idea why:-( Can u help me please.

Thanx

Have a nice Day

Object Variable Or With Block Variable Not Set (Error 91)?
hi i'm trying to get the firstname and lastname to show up on a html doc called certificate_cd.htm. there is a <h2 id="userName">&nbsp;</h2><p> reffering to the WebBrowser1.Document.All("userName").innerHTML
now if i have WebBrowser1.Document.All("userName").innerHTML uncommented, it gives me a run-time error of 91. but if i comment it out and have the msg boxes it does what i want. which is return the value of firstname and lastname. now, why am i getting that error when i try to set WebBrowser1.Document.All("userName").innerHTML= firstName & lastName? I've even tried to use cStr(firstName) & cStr(lastName).

help!

/a


Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Dim currLocation As String
Dim userName
currLocation = WebBrowser1.LocationURL
If (MH_BaseFileName(URL) = "testyourself") Then
UpdateQuizPage
ElseIf (MH_BaseFileName(URL) = "introduction") Then
Dim newURL
newURL = Mid(URL, 158)

Dim newURLarray
newURLarray = Split(newURL, "&")
firstName = Mid(newURLarray(0), 7)
lastName = Mid(newURLarray(1), 6)

ElseIf (InStr(1, currLocation, "certificate_cd") > 0) Then

MsgBox firstName & " " & lastName & "hi"
'On Error Resume Next
MsgBox firstName & " " & lastName & "hi2"
WebBrowser1.Document.All("userName").innerHTML = CStr(firstName) & " " & CStr(lastName)
MsgBox firstName & " " & lastName & "hi3"
'WebBrowser1.Document.All("userName").scrollIntoView (True)
End If
End Sub

Object Variable Or With Block Variable Not Set (Error 91)
If Data2.Recordset.EOF = False Then
While Data2.Recordset.EOF = False
Data2.Recordset.Delete
Data2.Recordset.MoveNext
Wend
End If

come out this error :
Data2.Recordset.EOF = <Object variable or With block variable not set >

I just want to delete the data in my database.

Thanks for helping me!

Object Variable Or With Block Variable Not Set Error.
Hi

I was wondering if anyone can see where I have done wrong that it gives me error of object variable or with block variable not set error on :

Set RS = DB.OpenRecordset(SQL)

My whole code is :

Private Sub Command1_Click()
Dim SQL As String
Dim RS As Recordset
Dim DB As Database
Dim x As Long


If Option1.Value = True Then
x = 1
End If
If Option2.Value = True Then
x = 2
End If
SQL = "Insert Into User " & _
"(Name, Gender, Age, Course, Field, Email) " & _
"Values " & _
"('" & Trim(Text1.Text) & "', " & x & _
"'" & Trim(Text2.Text) & "', " & _
"'" & Trim(Text3.Text) & "', " & _
"'" & Trim(Text4.Text) & "', " & _
"'" & Trim(Text5.Text) & "' )"

Set RS = DB.OpenRecordset(SQL)

End Sub

Private Sub Form_Load()
Dim DB As Database
Open "c: est.txt" For Append As #1
Set DB = OpenDatabase(App.Path & "/db3.mdb")
End Sub

Private Sub Form_Unload(Cancel As Integer)

Set RS = Nothing
DB.Close
Set DB = Nothing
End Sub

Object Variable Or With Block Variable Not Set - Error
Hi friends,

Please guide me to solve this problem.


VB Code:
ers!c1s1 = rss1.Fields("c1s1")

Making Pointer Of A Long Variable For Another Variable
My brains are having issues, so here we go:I have a Long variable that I want to contain a pointer value.I want to change the value of this variable to be pointer value to anywhere in the memory.The value of another Long variable should change to be the contents of the pointer.I just can't get my head to do it... very simple, just a change to one pointer value in memory, but how to do that?

Object Variable Or With Variable Not Set... Prevent This Error?
Im writing a program that parses only certain pages a user is viewing, then send information to a server

In my NavigateComplete2 event, I make sure the ie.busy = False and the url is the type of page I want

Code:
Dim hDoc2 As MSHTML.HTMLDocument
'Other Code
Private Sub ie_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
If ((InStr(1, ie.LocationURL, "page1.php") > 0 Or InStr(1, ie.LocationURL, "page2.php") > 0) And ie.Busy = False) Then
Set hDoc2 = ie.document
Dim tmp As String
Dim tmp2 As String
tmp = hDoc2.body.innerHTML

That last line is where it throws the error. It does it once every 20 times
(mostly on page2.php), and Im not really sure why. Is there another line or something I can put in the If statement to make sure the object is set?
I searched for about 20 minutes and found nothing

Sorry, Im really bad at VB. My specialty is php :/
Thanks


Bear

Copyright 2005-08 www.BigResource.com, All rights reserved