473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

RunTime error 91 : object variable or with block variable not set

1
I am getting Run time error 91 in below ** area.I couldn't figure it out where is the problem. What i try is, to avoid to enter duplicate pin number.

Expand|Select|Wrap|Line Numbers
  1. Public Function Custom_PIN(ByVal TableName As String, _
  2.     ByRef EmployeeCode As String, ByVal FieldName As String, ByVal DataToCheck As String, _
  3.     Optional ByVal CodeFieldName As String = Empty, Optional ByVal CodeFieldValue As String = Empty) As Boolean
  4.  
  5. Dim lstrSQL1 As String
  6. Dim lrsTemp1 As ADODB.Recordset
  7.  
  8.     lstrSQL1 = " Select  " & FieldName & "  from  " & TableName & " Where PIN_NO =" & DataToCheck & ""
  9.     'MsgBox (lstrSQL2)
  10.  
  11.     If Len(Trim$(CodeFieldName)) <> 0 And Len(Trim$(CodeFieldValue)) <> 0 Then
  12.        lstrSQL1 = lstrSQL1 & " AND " & CodeFieldName & " <> '" & CodeFieldValue & "'"
  13.     End If
  14.  
  15.     Set lrsTemp1 = cObjDBConn.ExecuteSQL(lstrSQL1)
  16.  
  17.     If lrsTemp1 Is Nothing Then
  18.         Custom_PIN = False
  19.     ElseIf Not (lrsTemp1.BOF And lrsTemp1.EOF) Then
  20.         Custom_PIN = True
  21.         lrsTemp1.MoveFirst
  22.         EmployeeCode = lrsTemp1.Fields("EMPLOYEE_CODE")
  23.     ElseIf lrsTemp1.RecordCount = 0 Then
  24.         Custom_PIN = False
  25.     Else
  26.         Custom_PIN = False
  27.     End If
  28.  
  29.     ***If lrsTemp1.State = adStateOpen Then lrsTemp1.Close
  30.     Set lrsTemp1 = Nothing ****
  31.  
  32. Exit Function
  33.  
  34. ErrorHandle:
  35.     Custom_PIN = False
  36. End Function
  37.  
Here is my calling Code

Expand|Select|Wrap|Line Numbers
  1. If gobjValidation.Custom_PIN(fstrTableName, gEmployeeCode, "EMPLOYEE_CODE", _
  2.             Trim$(TxtPINno.text)) = True Then
  3.             MsgBox (gEmployeeCode)
Jul 27 '15 #1
0 1123

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: dubing | last post by:
Hi, Our webpage uses the following JavaScript code. function toggleSubmenu(divId, link) { var div = document.getElementById(divId); div.style.display = (div.style.display == 'block') ?...
1
by: MARK | last post by:
When i attempt to set my 'picture' background for my sub-form i get the error "OBJECT BLOCK OR WITH BLOCK VARIABLE NOT SET". The main form has a background set using the 'picture' in the...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
0
by: RJN | last post by:
Hi Sorry for posting again. I'm calling a shared method in the class. The following error is found in production though I'm not able to reproduce. ...
5
by: mekon | last post by:
Hi All, I'm hoping someone out there can give me a hand with this problem I've got. I have an Access DB that people connect to using Access RT 2000. There are some machines that can connect...
1
by: oicit | last post by:
Hi, I'm new to VB.. Currently I want to do a test and program as the following..But nomatter how hard I try I always end up with this error message-object variable or with block variable not...
8
by: cloh | last post by:
Thanks to all the people who reply so promptly to my questions! I have another one related to the form I am working on. When I try to call this function from another, I get the "Object variable or...
5
by: Al G | last post by:
Hi, I'm converting a bit of POP3 VB6 code to VB2005, and have run into this error with the following code. Can someone help me find out what I'm missing/doing wrong? 'holds the attachments...
3
by: KChilingulo | last post by:
I've database in MS Access so when I try to input a record on the window which is applicable fot the receipts to be entered am getting this message. Would you assist as am stuck on this issue
4
by: munkee | last post by:
As topic says. Under normal database usage when I click quit I write to a log the current date/time. This is just for audit purposes to keep track of when people enter/leave the database. However,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.