No Current Record Error

05-28-2002, 02:56 PM
I have a program job quoting program that is giving me some problems. I use ADO to create new records in the database... every new record requires a new entry in 3 tables... here is the code that I use to add records:

Private Sub addrecord_Click()
Dim count As Integer

'Synchronize database and initiate new quote command
Set addcn = New ADODB.Connection
Set addrs = New ADODB.Recordset

addcn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" + Form4.Text2
addrs.ActiveConnection = addcn

addrs.Open "JobOrderData", , adOpenKeyset, adLockOptimistic
count = Val(addrs.Fields("QuoteNo"))
'MsgBox count

'increment quote number
addrs.Fields("QuoteNo") = count + 1
addrs.Fields("date") = Date
'MsgBox addrs.Fields("QuoteNo")

Set addrs = New ADODB.Recordset
addrs.ActiveConnection = addcn

addrs.Open "BillofMatl", , adOpenKeyset, adLockOptimistic
addrs.Fields("QuoteBM") = count + 1


Set addrs = New ADODB.Recordset
addrs.ActiveConnection = addcn

addrs.Open "QuoteSheetInfo", , adOpenKeyset, adLockOptimistic
addrs.Fields("QuoteNO") = count + 1


'MsgBox addrs.RecordCount

Form1.Text63 = count + 1

Unload Form4

'Goto the new quote created in form1
Form1.getrecord = True
Form1.Command11.Value = True


To access this new record I use the following DAO commands:

Private Sub getrecord_Click()

'Locate quote number (not active command)
Data1.Recordset.Index = "QuoteNo"
'MsgBox Text63

Data1.Recordset.Seek "=", Form1.Text63
If Data1.Recordset.NoMatch Then
MsgBox ("Check to be sure you have selected a valid quote no, or the quote number range")
End If

End Sub

This getrecord sub will work sometimes and other times I will receive NO CURRENT RECORD. I cannot figure out why it works sometimes and not others.

05-28-2002, 03:07 PM
I think I'd replace the DAO code with ADO code since that's what you created the record with, Why would you want to mix the two? Anyway, have you tried refreshing the datacontrol? I.E. data1.Refresh


05-28-2002, 03:15 PM
I am trying to fix this program that someone wrote completely using DAO. I added the records using ADO because it is easier and used DAO because every text box on the form is bound to data1. Is there a way to use ADO code without setting each textbox indivually like:

text1 = rs.fields("field1")

can I do something like:

form1.recordsource = rs

I have over 100 text boxes so it is no easy task.

05-28-2002, 03:44 PM
I believe you can use an ADO data control and bing the text boxes to that, does that not work for you?

05-28-2002, 03:48 PM
I didnt know that there was an ADO control is that a special add on?? How would I go about adding it to my toolbar?

05-28-2002, 03:52 PM
Project -> Components -> Microsoft ADO Data Control

05-28-2002, 03:54 PM
In the VB IDE press Ctl + t

That will open the component list. Select Micrsoft ADO Data Control from the resulting list. That will put it in your toolbox.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum