473,397 Members | 1,960 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,397 software developers and data experts.

Either BOF or EOF is True or the current record has been deleted

3
I am trying to get specific data by entering a value in a TextBox.
-----------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. Sub GetData()
  2.  blatt = ActiveSheet.Name
  3.     zeile = 1
  4.     spalte = 1
  5.     q = "select * from customers where country='TextBox1.Text'"
  6.    x = ODBCQueryDaten(q, blatt, zeile, spalte)
  7.     Range("A2").Select
  8.  
  9. End Sub
  10.  
  11. * This is the code when i hit the command button i made, where i get the msg"Either Bof or Eof etc.."
  12.  
  13. but if i change "TextBox1.Text" to a value like 'Germany' i would get the data correct.
  14. ------------------------------------------------------------
  15.  
  16. This is the code where it takes me after getting the error , if needed: 
  17.  
  18. Public Function ODBCQueryDaten(query As String, blatt As String, zeile As Long, spalte As Long) As Boolean
  19.     Dim rs As ADODB.Recordset
  20.     Dim smax As Long
  21.     Dim s As Long
  22.     Dim zmax As Long
  23.     Dim z As Long
  24.     Dim v As Variant
  25.     Dim w As String
  26.  
  27.  
  28.     'Datenbank verbinden
  29.     ODBCConnect
  30.     'Datensätze holen
  31.     Set rs = New ADODB.Recordset
  32.     rs.CursorLocation = adUseClient
  33.     rs.Open query, Conn ', adOpenForwardOnly, adLockOptimistic
  34.     'Spaltenzahl/Zeilenzahl
  35.     smax = rs.Fields.Count
  36.     'nix gefunden
  37.     If rs.AbsolutePosition = -1 Then
  38.         Worksheets(blatt).Cells(zeile, spalte) = "nix"
  39.     Else
  40.         rs.MoveLast
  41.         zmax = rs.RecordCount
  42.     End If
  43.         'Spaltenüberschriften
  44.         For s = 0 To smax - 1
  45.             Worksheets(blatt).Cells(zeile, spalte + s) = rs.Fields(s).Name
  46.         Next s
  47.         zeile = zeile + 1
  48.         'Zeilenwerte
  49.         rs.MoveFirst
  50.         For z = 0 To zmax - 1
  51.             'Spaltenwerte
  52.             For s = 0 To smax - 1
  53.                 'Wert konvertieren
  54.                 Set v = rs.Fields(s)
  55.                 If IsNull(v) Then
  56.                     w = "<NULL>"
  57.                 ElseIf IsEmpty(v) Then
  58.                     w = "<EMPTY>"
  59.                 Else
  60.                     w = Komma2Punkt1(v)
  61.                 End If
  62.                 'Wert in Zelle
  63.                 Worksheets(blatt).Cells(zeile + z, spalte + s) = w
  64.             Next s
  65.             'nächster Datensatz
  66.             rs.MoveNext
  67.         Next z
  68. '    End If
  69.     'Wert zurück
  70.     ODBCQueryDaten = True
  71.     'Datenbank schliessen
  72.     ODBCClose
  73. End Function

Thanks a lot , hope to get an answer soon
May 23 '14 #1

✓ answered by Seth Schrock

What program are you using? Part of the problem is that you are passing the literal text "Textbox1.Text" instead of the value inside the textbox. This is why it works when you plug "Germany" into it. Since there is no country named "Textbox1.Text", you won't get any records returned. You need to split the string out so that it can pull the value that is inside the textbox. Because of the Range("A2").Select line, I'm going to guess you are using Excel, in which case I'm not sure the proper way to reference the value in a textbox, so I'll leave it the same as how you have it and just do the concatenation portion.
Expand|Select|Wrap|Line Numbers
  1. q = "select * from customers where country='" & TextBox1.Text & "'"

4 1595
Seth Schrock
2,965 Expert 2GB
What program are you using? Part of the problem is that you are passing the literal text "Textbox1.Text" instead of the value inside the textbox. This is why it works when you plug "Germany" into it. Since there is no country named "Textbox1.Text", you won't get any records returned. You need to split the string out so that it can pull the value that is inside the textbox. Because of the Range("A2").Select line, I'm going to guess you are using Excel, in which case I'm not sure the proper way to reference the value in a textbox, so I'll leave it the same as how you have it and just do the concatenation portion.
Expand|Select|Wrap|Line Numbers
  1. q = "select * from customers where country='" & TextBox1.Text & "'"
May 23 '14 #2
Ronie9
3
Hello Seth , thanks a lot for the reply

yes im using excel and trying to retrieve specific data from mysql databas by giving a value in the textbox. now when i did what you wrote me i got the error msg"run-time erorr 424, object required"

I tried many things to get it work but still i cant get it to read the text from the textbox.

regards
May 23 '14 #3
Ronie9
3
thanks you very much , it works now fine

little change was
Expand|Select|Wrap|Line Numbers
  1. q = "select * from customers where country='" & UserForm1.TextBox1.Text & "'"
May 23 '14 #4
Seth Schrock
2,965 Expert 2GB
Glad you got it to work.
May 23 '14 #5

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

Similar topics

3
by: Maria | last post by:
Is there another way to delete the current record in a subform from the main form, another subform or a sub-subform other than setting focus on a field in the subform and using run command...
3
by: Prakash | last post by:
Below is my code to delete a record in a continuous form. I can't figure out any reason but sometimes (another) record gets deleted instead of where the record pointer is positioned. Small table...
6
by: jpatchak | last post by:
Hello, I have a main form with one subform. I have a command button on the main form to delete the current record. Below is my code. The tables on which the main form and subform are based...
3
by: Kosmos | last post by:
Hey ya'll...I can't seem to figure out why I'm getting this error message, but it all started when I added the new line of code with the recSet5.AddNew --- when I ran the first line, the logic worked...
3
by: marcf | last post by:
Hi Everyone, Hopefully someone will be able to offer a suggestion to this problem. I have a multi user CMS running at work which I wrote. Aside from a few bugs everything has been going fine...
1
by: THEAF | last post by:
i'm trying to create a reminder form, when i add a new reminder its ok but when i try to delete a reminder then i get No Current Record problem. Form Load Private Sub Form_Load() Dim s() As...
5
by: TimSki | last post by:
Hi, This is very strange... I have a simple query using a recordset thus... set rsID = CreateObject("ADODB.recordset") searchPhrase = "SELECT blah...." rsID.Open searchPhrase, oConn
1
vikas251074
by: vikas251074 | last post by:
Hello sir, I am facing some problem for which I am trying hard to solve it. But in vain. This programe is for View/Deletion. When I run program for first time, I select vlan from list and press...
4
by: jbrumbau | last post by:
Hello, I have a function that goes through each field in a form and checks if it was changed between itself and the existing recordset. It is used to track changes done in any record when the...
0
by: ramachandradurai | last post by:
hi, i am getting the error like.. Either EOF or BOF is true, or the current record has been deleted.Requested operation requires the current data. <%@ LANGUAGE="VBSCRIPT" %>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.