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




Moving To The Next Record Using VBA


Hi All - This is really bugging me. I'm trying to move to the next record located in a database. I can not use ADO I must use DAO. I've done this a million times in VB6 but something must be different in VBA(PS I'm doing eveyrthing in Access) because I can not get it to move to the next record. Any help would be greatly appreciated.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving To Record
I have a control on my form that copies the contents of a form and a subform to a new record. Here is my code. On my form, how do I find the new record? That is to say, once I copy the record, the "old record" is still the one on my form. I want to move to the "new record" as part of the copy function.


'copy record to new Quote record
intQuoteID = Forms![Bid - Master Form]![Bid - Quote]![Quote ID]
Set dbs = CurrentDb
Set rstQuote = dbs.OpenRecordset("Bid - Quote")
rstQuote.AddNew
intNewQuoteID = rstQuote![Quote ID]
Debug.Print "New Quote ID " & intNewQuoteID
Debug.Print "New Quote ID " & rstQuote![Quote ID]
Debug.Print "Old Quote ID " & intQuoteID
rstQuote![Master Bid ID] = Forms![Bid - Master Form]![Master Project ID]
rstQuote![Other Mfr] = Forms![Bid - Master Form]![Bid - Quote]![Other Mfr]
rstQuote![Comments] = Forms![Bid - Master Form]![Bid - Quote]![Comments]
rstQuote.Update
Forms![Bid - Master Form]![Bid - Quote].Requery

'copy quote items to new quote items records
strSQL = "Select * " & _
"FROM [Bid - Quote Items] " & _
"WHERE [Quote ID] = " & intQuoteID
Set rstOldQuoteItem = dbs.OpenRecordset(strSQL)
Set rstNewQuoteItem = dbs.OpenRecordset("Bid - Quote Items")
Do While Not rstOldQuoteItem.EOF
rstNewQuoteItem.AddNew
rstNewQuoteItem![Quote ID] = intNewQuoteID
Debug.Print "New Quote ID " & rstNewQuoteItem![Quote ID]
rstNewQuoteItem![Quantity] = rstOldQuoteItem![Quantity]
Debug.Print "Qty " & rstOldQuoteItem![Quantity]
rstNewQuoteItem![Description] = rstOldQuoteItem![Description]
Debug.Print "Description " & rstNewQuoteItem![Description]
rstNewQuoteItem![Finish] = rstOldQuoteItem![Finish]
rstNewQuoteItem![Price] = rstOldQuoteItem![Price]
rstNewQuoteItem![Comments] = rstOldQuoteItem![Comments]
Debug.Print "Comment " & rstNewQuoteItem![Comments]
rstNewQuoteItem.Update
rstOldQuoteItem.MoveNext
Loop
Forms![Bid - Master Form]![Bid - Quote]![Bid - Quote Items]


Thanks is advance
Scott

Moving A Record
Hello Guys,

Im using a control called Adodc i was woundering if anyone can tell me how to move a record from tblName to tblSecondName with a click of a command button.

I use the followind code to save a record.?


vb Code Code:
If MsgBox("Are you sure you want to save the record?", vbQuestion + vbYesNo, "Saving...") = vbYes Then
Adodc2.Recordset.Fields("Subject") = cbosub.Text
Adodc2.Recordset.Update
distext
End If

Moving To A Record
I have a many side of a relationship in a table.
So ive created a form etc etc. Say Im looking at record #1
for simplicity lets say its an orders form with an order-details within it. Im looking at record 1 and it shows that it has 40 order details. I have a next / previous button and a first last button. What if I wanted to go to order detail #30 Id have to either keep pressing up or press first once and move down to 30. I dont want this. I want a text box that a user can enter the record they want to look at and it moves directly to it on hitting the enter key.

How do I do this via ADO?

Jon

Moving To The Next Record Ms Sql & Vb
Hi, im kinda new to working with vb and sql server, i need to be able to scroll through records but i have no idea how. As of right now my code is:
CODEDim cn As ADODB.Connection
Dim RS As ADODB.Recordset
Dim strSQL As String

Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset

cn.Open "Driver={SQL Server};Server=server;Database=mydata;uid=;password='';"
strSQL = "select * from mytable"

RS.Open strSQL, cn, adOpenStatic, adLockReadOnly

Not Moving To Next Record
hi

all my staff will view for datas in this form. i am using scene table and panel table.

once they select scen1cbo(sceneid), other data will populate but now only one data is populated when i click 1 sceneid. It has more records linked to that sceneid.

(sceneid)SE01 A (panel field)
              B
                       C
                       D
when i select SE01 it displays 'A' alone i can't able to move to the next records B, C, D.

how to do that?

Code:Private Sub scenecombo_Click()

myquery = scenecombo.Text

Call rLOAD

 Do While storyboard!scenes <> myquery
 storyboard.MoveNext
 If storyboard!scenes = myquery Then
 panel_txt.Text = storyboard!Panel
 sequcombo.Text = storyboard!sequence
 action_txt.Text = storyboard!Action
 dialogue_txt.Text = storyboard!dialogue
  Image1.Picture = LoadPicture(App.Path & "images" & storyboard("filename"))
  End If
 Loop
 
accdb = "SELECT * FROM scene WHERE sceneid = '" & myquery & "' "
'Load SQL query into a variable

Set storyboard = CON.Execute(accdb, adOpenStatic)

End Sub

Moving To A Record
In an adodc recordset i want to move to a certain record and then return to the original record.
The code should look something like that:
sub cmd MoveTwice()
dim intOriginalRec as integer
intOriginalRec = adodc1.recordset.bookmark
adodc1.recordset.movelast
rem now i want to go back to the originalecord
addc1.recordset.GOTO(INTORIGINALREC)
End Sub


GOTO(INTORIGINALREC) is a method i invented of course. I'll be very gratefull to anyone who could teach me what method or what should i write instead! Thanks in advence !

Could Someone Help Me In Moving My Record Pointer?
hi there!
i m using data control in my form. when i reach eof moving record pointer to next record, realising eof i try to move it to last record or previous record. but the error message is same all the time... "This operation is cancelled by an associated object"!

I have tried each and every possibility.. including recreating database.. but problem persist..
i m tired of this problem and i give it up to you! would you help me out please?????

Moving To The Last Record - Vsflexgrid Used
im displaying records to the vsflexgrid, im using a view to call the records. i have a button "New" which adds a new row to the grid when pressed. what i want to do is, when i press "new" the cursor will automatically go to the empty row so that i wont have to use the scrollbars just to go down to the empty row.

i display the records in my form_load event

Code:
Set rs = New ADODB.Recordset
Set clsADO = New clsADO

Set rs = clsADO.objBrowse(browser)
Set vsf_library.DataSource = rs

and in my New button:


Code:
vsf_library.Rows = vsf_library.Rows + 1 ' adds an emty row

what shall i add in my "new" button then so that the focus will be in the empty row already?

Moving To Next Record On An Error
Hello everyone. I am writing a program that has 5 nested SQL statements. If the first statement does not return anything, then I get and error right down the line. Is there a may to say on error move to next, loop and continue? Everything I have tried is generating an error or doesn't work. Thanks.

Steve

Movelast Not Moving To Last Record : (
hey all,

I have a confusing problem here and i would greatly appreciate any help, thanks guys :)

ado data controler : adodc1 with text boxes etc bound to this, i can add and update records no problem, but when i go adodc1.movelast it moves to the record precding the one i just added, i close the program and try it again, same story, i can search for records and find them, but i cannot browse to them using movenext or movelast, any ideas??

thanks in advance


Moving To Next Record In A Subform Using VBA In A Form?
If I have a regular Access 97 form with no recordset whatsover which merely displays a subform- (the subform of course has a series of records but not the form)? How can I make that subform do a DoCmd.GoToRecord , , acNext using VBA from within the form only?

Moving The Recordset To A Specific Record?
Hey all,

I have a table with a primary key, and the last column of the table stores numbers.

what i want to know how to do is, if i wanted to edit the last column of any particular record, how would I tell the recordset to move to that record by using the primary key as the criteria?

ie. If i wanted to edit the last column (called "seats"), for the record with primary key number 145, how would i do it?



Code:
Dim rs As Recordset
Dim Db As Database

Set Db = OpenDatabase(App.Path & "db1.mdb")
Set rs = Db.OpenRecordset("Flights")

rs. ?????

rs.edit
rs!seats = blablablabla
rs.update
rs.close
db.close

the question marks are where i dont kno wat to do

Moving To Next,previous,first,last Record Problem
Thank you
its me again, sad to say but im encountering a new problem in viewing my file
in this problem im encountering problem
when i press the next and previous button it does'nt show the message box warning and on when i click
the next button it only move once and when i click previous it displays an error that
operation is not allowed in this context and when i click the last button
it will say that rowset doest not support fetching backward
i look at ADOTUT file and the code i use is almost the same except i use textbox instead of listbox
i also try the DO UNTIL syntax but still i encounter errors
What could be the problem?
Please Help Me



Code:
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub Command1_Click()

Set conn = New ADODB.Connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0;"
conn.Open (App.Path & "cmsdb.mdb")

Set rs = conn.Execute("SELECT lastname FROM cmstable")


If rs.EOF = True Then MsgBox "no more records"

rs.MoveNext
lname.Text = rs("lastname")

conn.Close

End Sub

Private Sub Command2_Click()
Set conn = New ADODB.Connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0;"
conn.Open (App.Path & "cmsdb.mdb")
Set rs = conn.Execute("SELECT lastname FROM cmstable")

If rs.BOF = True Then MsgBox "no more records"
rs.MovePrevious
lname.Text = rs("lastname")

conn.Close


End Sub

Private Sub Command3_Click()
Form3.Show
Unload Me
End Sub

Private Sub Command4_Click()
Set conn = New ADODB.Connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0;"
conn.Open (App.Path & "cmsdb.mdb")
Set rs = conn.Execute("SELECT lastname FROM cmstable")


rs.MoveFirst
lname.Text = rs("lastname")

conn.Close
End Sub

Private Sub Command5_Click()
Set conn = New ADODB.Connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0;"
conn.Open (App.Path & "cmsdb.mdb")
Set rs = conn.Execute("SELECT lastname FROM cmstable")


rs.MoveLast
lname.Text = rs("lastname")

conn.Close
End Sub

.MoveNext Isnt Moving To Next Record...
Hey guys/girls:

I am attempting to use .MoveNext for the first time. I am loading the first record to the app on form load, and when you click on the Next button, it should go to the next record and display it. However, it's not displaying anything. It's staying at the first record all the time. Any chance someone can take a look at the attachment and let me know where I am going wrong pls?

Thanks in advance for your help.

Problems With Moving To Next Record In Loop
The code is working fine for the first run through, adding the updating the appropriate fileds but it doesn't work for the other six records or so. Any ideas why?


Code:

Do Until rstBaseTable.EOF

MidTextTel = Mid$(iTelNum, 1, 3)
dtaPaymentTable.Refresh

Set rstPaymentTable = dbsPhone.OpenRecordset("SELECT CallPrice FROM PAYMENT WHERE CallPrefix = '" & MidTextTel & "'")
PriceAsInteger = CSng(txtCallPrice.Text)
Debug.Print PriceAsInteger; "PRICEASINTEGER"

Set rstBaseTableCalc = dbsPhone.OpenRecordset("SELECT Duration " _
& "FROM BASE " _
& "WHERE TelNum Like ' & MidTelText &*';")

dtaBaseTable.Refresh
DurationAsString = CStr(txtDurationBase.Text)
CallCost = PriceAsInteger * DurationAsString

AddCallCost rstBaseTableAdding, CallCost

If rstBaseTable.RecordCount > 0 Then

rstBaseTable.MoveNext

End If

Trying To Stop Moving Past Last Record
I am writing a database with a number of tables with forms atttached to each table. I have placed navigation buttons on each form to move to first, last, next, previous. I have set up the code associated with the buttons as "public sub" so it is available for each form to use.

This was working OK except that when I used the NEXT button at the last record it would open a new blank record & keep opening a new blnak record on each click.

To over overcome this I put in an If statement to check if it had moved to a new record. To do this I used the following:

If Me!NewRecord Then ..... etc

Now I get an error "Invalid use of Me key word" I suspect it is because I am using ME in a public sub

How do I overcome the problem of moving passed the last record and still have the coding available to all forms?


The Code is below.

Thnaks for any help.


Public Sub Next_Record_Click()
On Error GoTo Err_Next_Record_Click

    DoCmd.GoToRecord , , acNext

If Me!NewRecord Then
    ' If new record move back to previous
    DoCmd.GoToRecord , , acNext
    ' Send message
    MsgBox "This is the last record", , "No More Records"
    
End If


Exit_Next_Record_Click:
    Exit Sub

Err_Next_Record_Click:
    MsgBox Err.Description
    Resume Exit_Next_Record_Click
    
End Sub

Moving From One Record To Another In Continous Form
I have a small problem, got a continuos form created by using wizard in Access. One of these field is a checkbox, and are in each row. What I would like to do is to move from Firstrecord to Lastrecord and count for each record if these checkbox field is ticked(true). At the end I would like it prompted to me the number of true checkbox in MsgBox.

Main thing is I don't know how I can get a result for more than one record. Someone please show me a snippet of code to solve this problem, please

Moving Control To Previous Record Field
I hope this is the right forum for this...

I have an Access 2000 sub-form with a bit of VB programming behind it. The fields are layed out like this -

Field1 Field2 Field3

Fields 2 and 3 have some error checking that works fine. Problem I have is that when Field3 finishes it's error checking it creates a new record and goes to Field1 of the new record, leaving a null value in Field3 of the previous record.

Can I somehow do the error checking in Field3 and then have the focus stay there?

Thanks all!
John

Moving To A Different Record In A Recordset Based On Clicking On A DBLIST
Okay, I have an issue with VB 6.0/DAO 3.51 that I can't get around. I have 2 DBLists that display lists from 2 different fields of the same table that are driven by one SQL query at runtime. I can get the lists to display, but I am having trouble navigating the lists. The operator needs to be able to click on either list and have the other list update to have focus on its specific field of the same record. I initially tried just to select the next item on the list and get the other list to update using the recordset.movenext & recordset.moveprevious methods. I get an error when doing this that says the "Object doesn't support this property or method"

The wierd thing is that the dblists still kind of do what I want after acknowledging the error. I select the item in the list, I get the error, I acknowledge error, then both updates move to the next item in the list. The application doens't crash. I am a bit confused. Here is my code. Thanks, in advance for any assistance.
______________________________________________________
Private Sub DBList2_Click()
Data1.Recordset.MoveNext
End Sub

Private Sub Form_Load()
DBList1.DataField = "ntaID"
DBList1.ListField = "ntaID"
DBList2.DataField = "taskdescription"
DBList2.ListField = "taskdescription"

Data1.RecordSource = "SELECT * FROM nmetls ORDER BY ntaID;"
Data1.Refresh

End Sub
________________________________________________________

Moving To Next Record, And Updating Data Bound Controls
Hey guys,

have a problem. i am forced to use DataEnvionment so dont suggest otherwise. i know it sux.

anyway i have a few controls which is kind of 'data bound' to a recordset in a data environment.

now i want to do a simple record navigation.

like .movenext, etc.

but when i movenext from the Recordset, the DataBound controls doesnt update with the new data. infact, nothing visibly happens.

any suggestions ?

this is the code im using

Private Sub cmdNext_Click()
If DataEnv.rsLect.State <> adStateClosed Then DataEnv.rsLect.Close
DataEnv.rsLect.Open
DataEnv.rsLect.MoveNext
DataEnv.rsLect.Close
End sub


thanks
Deane.

Code For Moving To The First Blank Cell In A Worksheet; Moving Left,right,up Or Down
I have created an application form as a userform in Excel. I need to send the data entered into my text boxes when the program runs to separate excel cells in a worksheet.

My problem is I can use code that will send the textbox entry to a specific cell eg. If my textbox is named Surname I can say

range("a5").value = surname but if I do that when I run the programme to enter the next record for someone else the first record will be overwritten.

I NEED A CODE LINE THAT WILL TAKE ME TO THE FIRST EMPTY CELL AND ALLOW ME TO MOVE DOWN OR TO THE LEFT OR TO THE RIGHT

Moving A Record From "inventory" Table To "trash"
Hi All,

I am trying to create a "Trash" button instead of a "Delete" Button which first copies the record to another table and then deletes the record.

I am trying with the code below but its not working and gives Run-Time Error '91' -"Object variable or With Block variable not set" the very first time in "Adodc2.Recordset.AddNew" line :

Adodc1 is connected to the "Inventory" table and Adodc2 is connected to the "Trash" table. Both tables have the very same fields in the same order. Remamber the records are being deleted from the Inventory table (which will never have 0 records). I have also programmed the delete from the "trash" which works fine. My BIGGEST problem is copying a particular record from the Inventory table to the Trash Table.

Private Sub cmdtrash_Click(Index As Integer)
Adodc2.Recordset.AddNew
Adodc2.Recordset("ID") = Adodc1.Recordset("ID")
Adodc2.Recordset("Site") = Adodc1.Recordset("Site")
Adodc2.Recordset("Address") = Adodc1.Recordset("Address")
Adodc2.Recordset.Update
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext

PLEASE HELP...... I AM DEAD STUCK

Rs.Update Record Updates Next Record Not Current Record Access DB
For some reason I can't find (lack of VB knowledge obviously) the record that I want to update is updated in the following record and not in the current record.... I'm using Access 2002 database and VB 6. Here is the code: (the DB is opened with "methodaccessdatabase" in a module)

Code:
Option Explicit
Private Sub Form_Load()
    Skin1.ApplySkin Management.hwnd
    methodaccessdatabase
    Set rs = db.OpenRecordset("Responsibility")
End Sub
Private Sub Command1_Click() 'Next record button
    If Not rs.EOF Then
        Text1 = rs(0): Text2 = rs(1): Text3 = rs(2)
        rs.MoveNext
      Else
        rs.MoveFirst
    End If
End Sub
Private Sub Command2_Click() 'update record in database
    rs.Edit
    rs(2) = Text3.Text
    rs.Update
    rs.MoveNext
End Sub

The database has only three fields, the one I want to update is field (2 = responsible) jpeg of DB attached...it seems soo simple but I'm stuck!


Thanks
vbprog1144










Edited by - vbprog1144 on 2/10/2004 6:03:37 PM

Moving Balls To Moving Images??
Please take a look at this as it is related to my question
Thread

is it possible for the create images to be an image type that is already drawn?

Trying To Input Single Record Number To Textbox And Display Individual Record
Have an input textbox "txtEnterRecNum_LostFocus()", trying to get it so that the user can enter a single record number (1-10) and then THAT one record displays in another textbox "txtDisplayIndividual.Text"

Have coded it to singlely accept one number (for example it is set at number 5), that is ok ... having problems expanding to determine if it's 1,2,3,4,5,6,7,8,9 or 10.

I've played with Do While, Do Until, Ten episodes of IF's (that is long and hokey), tried OR's, tried i <=10, etc., but am not coding correctly as nothing has been successful.

(1) How would I change the following single acceptance code below, to FIRST accept numbers 1,2,3,4,5,6,7,8,9 or 10 and THEN display that particular record?

Code:
Private Sub txtEnterRecNum_LostFocus()
Dim i As Integer
i = 0
Open GetAppPath & "mytext.txt" For Input As #1
Do Until EOF(1)
i = i + 1
Input #1, SampleOutput
If i = 5 Then
txtDisplayIndividual.Text = SampleOutput
Exit Do
End If
Loop
Close #1
End Sub
(2) When it does work for one number, the record displays only if one clicks inside another object/input textbox ... How to make it work no matter where the user clicks on the form?

(3) And how to make it work by pressing ENTER key on the keyboard? (maybe this one is too complicated?)

.edit Adds New Updated Record Instead Of Saving Changes To Existing Record
hey everyone,

i'm creating an interface for an Access database using DAO, and one of my options is to edit a record. the code i'm using is recordset.edit ...then the textbox names that the record the user is editing is being displayed in..then the recordset.update. when i run the program, edit a record and save it, it creates another identical record just with the changes that i made to it. so i have the original record plus a new updated record in my database. any ideas how i could get it to just save the changes to the existing record? Also another quick question...is there any kind of code that maximizes the forms everytime you run the program?

i would appreciate any help, thanks

Suppress Record Without Equivalent Record To Other Table Using SHAPE Command
hi..i have this code for creating a report ...is it possible if i limit my query to those Employee that has a transaction only?? this code returns all the employee records even the ones without transactions....


Code:

Private Sub Command1_Click()

If cmbselect.Text = "EMPLOYEES" Then
'this shows the preview window for the report

DataReport1.Show vbModal
'DataReport1.Refresh

ElseIf cmbselect.Text = "CUSTOMERS" Then
DataReport2.Show vbModal
'DataReport2.Refresh

ElseIf cmbselect.Text = "UTILITIES" Then

DataReport3.Show vbModal
' DataReport3.Refresh

ElseIf cmbselect.Text = "SUPPLIERS" Then
DataReport4.Show vbModal
' DataReport4.Refresh

End If

End Sub


' ============= DATAREPORT1 ==============
Private Sub DataReport_Initialize()
Dim strSQL As String
Dim strTo As String
Dim strFrom As String
Dim oConn As New ADODB.Connection
Dim oRS As New ADODB.Recordset

oConn.CursorLocation = adUseClient
oConn.ConnectionString = DataEnvironment1.Connection1 ' were going use this because it's already done, but you could make your own.

oConn.Open



With frmEmpRep
strTo = .DTPicker1.Value
strFrom = .DTPicker2.Value

End With
DataReport1.Sections("Section2").Controls("lbldate").Caption = strTo

strSQL = "SHAPE { "
strSQL = strSQL & "SELECT tblEmployee.* FROM tblEmployee WHERE Type LIKE 'Employee' "
strSQL = strSQL & "} AS Command1 "
strSQL = strSQL & "APPEND ({ "
strSQL = strSQL & "SELECT tblTransaction.* FROM tblTransaction "
strSQL = strSQL & "WHERE DateTrans "
strSQL = strSQL & "BETWEEN #" & strFrom & "# "
strSQL = strSQL & "AND #" & strTo & "# ORDER BY BALANCE DESC "
strSQL = strSQL & "} AS Command2 "
strSQL = strSQL & "RELATE 'ID' TO 'ID') "
strSQL = strSQL & "AS Command2 "
oRS.Open strSQL, oConn, adOpenForwardOnly
Set DataReport1.DataSource = oRS


End Sub

How Can I Know Record Existancy By The Time Of Entering Record Code And Hit The Enterkey
Hi

please tell me that how can i find a record already exists or not while i'm typing the record code.

For example, I want to add a product description.When i press the enter key after entering the product code in a text box, it should display the product code already exists, if so. Ohterwise i should continue.

I'm using Accesss 2000, so, what can be done in keypress event of record code text box in Access Form.

Help me to know this.

Thanks
EmmanuelJKM

How Do I Show A New Added Record On A Datagrid Locked To A Child Record?
I have 2 datagrids on my form. One locked to the parent table and the other to the child table using the standard Dataenvironment method.
This shows existing child records OK as I change the parent record. When I add a new record to the child table using a separate recordset method, how do I show this addition in the child datagrid? At present I have to stop the program and restart it to see the new record. I've tried all the refresh and rebind thingys I can think of, at the end of my addnew code, without success. I cant find a way of refreshing the child command of the parent in the dataenvironment except in the design mode?
Regards Ted

Searching For Record In DB Doesn't Move To Found Record!! GOING INSANE!!!
I have been working on this for days, and cannot for the life of me find a solution.

I am trying to search for an entry in "TempTable" table based on the value from a record in "Seat" table. If it doesn't exist, then it copies the entry from "Seat" to "TempTable" However, if it is found, then all I need to do is edit the found result in "TempTable"

Nothing that I have used (seek method, findfirst methods, find method, with any combination of connections types) will work. The record may be found (I'm not sure), but the recordset position doesn't move to the result. I would use SQL, but when I do SELECT, it ignores all plank records, and I need to use all the records to keep track of where I am in the database. The "Seat" table has 703 records, some blank, and some not. I would like to be use .absoluteposition to figure out which record that I am at, but if nothing moves, I can't keep track of where I am in the Database. It is imparative that .absolutepostiion use all the records.

Please take a look. Suggestions are GREATLY appreciated. I am going INSANE working on this!!!

Code:
Dim NewTable As TableDef

Dim dbSrc As Database

Dim rsSrcRes As Recordset
Dim rsSrcPrc As Recordset
Dim rsDesTmp As Recordset

Set dbSrc = OpenDatabase(DefaultLocation + "Database" + ActiveFile_Event)
Set rsSrcRes = dbSrc.OpenRecordset("Seat", dbOpenSnapshot)
Set rsDesTmp = dbSrc.OpenRecordset("TempTable", dbOpenDynaset)
  
rsSrcRes.MoveFirst
 
Do Until rsSrcRes.EOF
   If rsSrcRes.Fields("Reserved").Value <> "" Then
       
        rsDesTmp.Seek "=", rsSrcRes.Fields("Reserved").Value 'Doesn't work
        rsDesTmp.FindFirst "Name = '" & rsSrcRes.Fields("Reserved").Value & "'" 'Doesn't work either
        checker2 = rsDesTmp.AbsolutePosition 'Aboslute Position never changes, so the found record is never moved to
        
        If rsDesTmp.EOF Then 'add new entry to temp table
             'code for adding new record with rsSrcRes.Fields("Reserved).value
        End If
    
        ' code for editing the fields in the search result in "TempTable"
            
   End If
   rsSrcRes.MoveNext
Loop




Edited by - austio on 2/1/2006 7:18:51 AM

How Can I Know Record Existancy By The Time Of Entering Record Code And Hit The Enterkey
Hi

please tell me that how can i find a record already exists or not while i'm typing the record code.

For example, I want to add a product description.When i press the enter key after entering the product code in a text box, it should display the product code already exists, if so. Ohterwise i should continue.

I'm using Accesss 2000, so, what can be done in keypress event of record code text box in Access Form.

Help me to know this.

Thanks
JEKM

Entering Record Number And Trying To Display Individual Record
Have an input textbox "txtEnterRecNum_LostFocus()", trying to get it so that the user can enter a single record number (1-10) and then THAT one record displays in another textbox "txtDisplayIndividual.Text"

Have coded it to singlely accept one number (for example it is set at number 5), that is ok ... having problems expanding to determine if it's 1,2,3,4,5,6,7,8,9 or 10.

I've played with Do While, Do Until, Ten episodes of IF's (that is long and hokey), tried OR's, tried i <=10, etc., but am not coding correctly as nothing has been successful.

(1) How would I change the following single acceptance code below, to accept numbers 1,2,3,4,5,6,7,8,9 or 10?
Code:
Private Sub txtEnterRecNum_LostFocus()
Dim i As Integer
i = 0
Open GetAppPath & "mytext.txt" For Input As #1
Do Until EOF(1)
i = i + 1
Input #1, SampleOutput
If i = 5 Then
txtDisplayIndividual.Text = SampleOutput
Exit Do
End If
Loop
Close #1
End Sub
(2) When it does work for one number, the record displays only if one clicks inside another object/input textbox ... How to make it work no matter where the user clicks on the form?

(3) And how to make it work by pressing ENTER key on the keyboard? (maybe this one is too complicated?)

Using ADODB.Record To Pull A Single Record From A Recordset
I am attempting to pull a single record from a recordset to pass to a function for populating a chart. What is the best method to do this. I am having a problem opening the record from the recordset.

 Dim rsChartData As ADODB.Recordset
 Dim rData As ADODB.Record

... Get the recordset from a storedprocedure via a command object

Set rData = New ADODB.Record
Set rData.Source = rsChartData
rData.Open rsChartData

 I am getting an error "Object or provider is not capable of performing requested operation."

If anyone can help with this it would be appreciated. Also, if there is a better way to pass the record, other than each individual field as a variable, please plass that on.

Thanks

How To Read The Database Record And Assign All The Record To An Array.
hi,

Is there anybody have any idea on how to read the database record and assign all record to an array. says i have 3 records, and how can i assign all these 3 records to an array, number of database records might be vary from time to time, say now is 3, but, later, might be 4 or 5... so, i assume here we have to used a dynamic array... my purpose is to read whatever record available in the database and assign all records to an array.

your help is very much appreciated.

biosphere

How To Locate The Last Record In Database And Get Its Value To Generate A New Record
I have a program in VB6 that gathers informtion from the user (Data entry) and has to generate a reportID in an Access Data Base. I would like to know if somebody can give me a clue and code to search the value of the last record, assign it to and auxiliar variable, index it in 1 and assign the new number to the variable Report_Id to add a new record in the database.

I would like to do that with SQl. But I´m open to other ways to do that.

I really appreciate your help.

Dario

Check Record Exists When Find A Record
how can i check record exists when find a record using

Rec.Find "Stno=" & txtStno.Text

if no record is there how can i check it

Search For A Record Using SQL And Then Put The Recordset's Pointer To This Record
Hello !
I have a database with one open recordset.
For example an Sql Query for "Users".

Now i do a search using a second recordset and get the primary
key for a specific user.

What i want to do , is to move the pointer of the
first recordset to the User record we found in the second recordset.
I know the primary key of the record found in the second recordset.

The first recordset is not just a simple table but an SQL Query that
includes the primary key.

i do not want to do a while loop since it may get slow

Thanks !

Datareport: Show Only One Record, Not Every Record In The Database
is there a way to get a datareport in VB to show only one record. i have the user choose from a list in my program and i want to use that choice to decide which record is displayed. the list contains all of the items in a distinguishing field in my access table. i want this so that when i print the report, it only prints the record chosen, not every record in the database table.


thanks, PJ

Copy Record 1 From Database To Paste In Last Record
hi to all,

have same dificulties in figuring out this problem of mine, dont know if it was already discuss but any need some pointers or assistance on how to achive this.
it started as I have a database in ms access with two tables company and description and Iam using msdatashape to combine the two tables when I add it runs with an autonumbering of records what I want to achive is when I select sample a record No.2 I want to copy all the information from that particular record No. and paste it in the last record with the new auto number. can this be done? but for sure you all out there knows this better than me so please need guidance. thanks in advance.



iloy

Get Sum Of Parent Record And Child Record Using Datashape
hi guys! anybody knows how to get the
sum(CALOTH.TOT,CHILDTBL.AMT,CHILDTBL.DEDAMT), you see i need to
get the total value of these fields, CALOTH is my parent table
and CHILDTBL is my childtable in my datashape, afterwards i will
display it on the datareport. note the code below...

rs.Open "SHAPE {SELECT * FROM CALOTH WHERE period1='" &
dhired.Value & "' AND period2='" & vcDTP1.Value & "'} AS
rsCALOTH APPEND " & _
"({SELECT * FROM CHILDTBL WHERE date1='" & dhired.Value
& "' AND date2='" & vcDTP1.Value & "'}AS rsCHILDTBL " & _
" RELATE emp_id TO emp_id)", conn, adOpenStatic,
adLockBatchOptimistic

Set PayslipRpt.DataSource = rs
PayslipRpt.Show

How To Record The Current Record Number In A Recordset??
glbRecSet.MoveFirst
Do While Not glbRecSet.EOF
  MsgBox "Account Number = " & glbRecSet("AccountNumber"), vbOKOnly, "Search Results"
  glbRecSet.MoveNext
Loop

This works fine, but what I want to do is have the it also tell me that this is, for example, record 1 of a total of 5 records in the recordset.  I know how to use ".RecordCount" to return the total number of records, but how do I return the number of the current record in the recordset?

Thank you
Kevin

Return New Record Or Record Affected In DataReader ???
I need to know what is the contact_id assigned in the new record !!!
HOW I DO ?
I try to do this but doesn't work

Example
Code:

' Contacts Table
' contact_id
' name
' last_name

       
        vSQL = "INSERT INTO contacts(name,last_name) VALUES('JEFF','SMITH')"        

        Dim CMD As New System.Data.OleDb.OleDbCommand(vSQL, StrConnection)
        Dim dr As Data.OleDb.OleDbDataReader
        Connection.Open()
        With CMD
            .CommandType = CommandType.Text
            dr = .ExecuteReader()
            .Dispose()
        End With
        Connection.Close()

    '????????
    MsgBox(**** CONTACT_ID ASSIGNED ****)
    'HOW SHOW THIS VALUE ???????    
    
        
 




really thanks

New Added Record Overlaps The Pervious Last Record... Help Pls.
hi guys! I'm having problem in saving the records...

Actually my programs saves the new record but it overlaps the last record in the database and everytime i try to move the pointer to make room for the new record, it shows an error message, here the error:

Run-time error '3315':
Field'employees.loginname' cannot be a zero-length string

error appears when use the "Update" for saving the database.

I also paste the codes to be more clear... I hope that you can help me with this problem.

Private Sub cmdsave_Click()
reply = MsgBox("Save New Record Now?", vbYesNo)
datuser.Recordset.MoveLast
If reply = vbYes Then
With datuser.Recordset
.AddNew
.lastname = txtlastname
.firstname = txtfirstname
.MI = txtMI
.address = txtAddress
.loginname = txtuser
.userpass = txtpass
.userposition = txtposition
.Update
End With
End If
locktextuser
End Sub

thanks!!! I appreciate your help!

Creating A Record, Bad Record Lenght
Hello,

How do I create a record with 1 array containing strings?
I get bad record lenght (error 59 ) when trying create it as String. (I tried also Variant) but then it says that VB does not support it. I guess I dont understand the underlying logic.

I open the file like this:
Open "Record.ini" For Output As #Fnum Len=Len(Recs)
Put Fnum, 1, Recs

I have defined variables like this:

Type ProfileFile

lblText(1 To 16) As String

End Type

Global Profile As ProfileFile


anybody knows?

For I And EOF ... Record Show Only Fist Record HELP
For i = 0 To rsDropdown.EOF
cmbCountry.AddItem rsDropdown.Fields("S_COUNTRY"), i
rsDropdown.MoveNext
i = i + 1
Next i

Record In Treeview,can Not Swich Record
Hi

Can som help me ???

I use this code to read data to treeview
Bud when I gat same name 2 I can not select I only can select
record 2 not 1 so I can not change record 2 to 1 If i gat the name john tvise, ??? I need to call the record ID and display the name
and when I select the name I read the ID to select record

Can som help me How????



On Error Resume Next
Dim nodType As Node
Dim intTypeKey As Integer
Dim rsTypeChild As ADODB.Recordset
Dim myTypeKey As String
'Select * from Login Where UserName=

strSQL = "select * from bókun where stađa = 'Í vinnslu' and nafn = '" & txtstadur.Text & "'"

' strSQL = "Select * From Bókun Where Where stađa = 'Bókun' "
Set rsType = New ADODB.Recordset
rsType.Open strSQL, conTree, adOpenStatic, adLockOptimistic

Dim i As Long
With tvwAM.Nodes
.Clear
For i = 1 To rsType.RecordCount
Set mNode = .Add(, , , rsType.Fields!Nafn, 2)
rsType.MoveNext
Next i
End With
rsType.MoveFirst

lblRecCount = rsType.RecordCount & " Fćrslur"
End Sub

New Record/delete Record In An Access .mdb
Probobally been asked before, but I searched and it's the first thing I haven't been able to find.

I have an access 97 .mdb, visual basic 6
I want to add new records to my .mdb file, and also delete them. I don't know where to start...

please help and I will shower you with gifts(not real ones, but you wan't to help me anyway)

Update A Record With A Column On The Same Record?
I'm trying to copy an entire column of data for every record that meets a certain criteria into another column in the same table. Tried this but it doesnt work


Code:
UPDATE Players SET Players.AlternateValue = [Players].[Value];

Ideas?

Record Locking At Record Level
I can't seem to write a demo program that show recordset locking at the record level before it's been editied.

I have set the parameter

Connection IsolationLevel=adXactReadCommitted
ServerSide Cursors
Pessemistic Locks.

I have 2 recordset variables. Both Accessing the same record. I would
have thought that once 1 RS is opened the other would not be allowed to
open it until it has been released, but this doesn't seem to be the case.

Can anybody point me in the right direction or some sample code.

Thanx in advance.

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