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




Autonumber And Current Record In Datagrid


Trawled threads but can't find specific answer to my prob. Have got a datagrid (properties: not updatable/no additions nor deletions). Data (ADO recordset stored in an Access 97) file uses client cursor/keyset/pessimistic locktype and is bound via dataenvironment. On the form I have controls (dropdowns and textboxes) with an "Add" button which adds (and automatically updates via code [rs.update]) a record to the datagrid. Data integrity/validation are OK. However, my primary key is an autonumber field (to which I obviously do not assign a value when adding a record) that doesn't seem to accept the next autonumber. I get a "0" displayed in the datagrid. I have a "Details" button, that when pressed, runs a query based on the recordset in the datagrid (with the .filter = autonumber of the current record in the datagrid - but taken from the actual rs.fieldvalue not the datagrid cell), displaying the data in a msgbox. This query runs fine as long as I don't attempt to call the current new record. Any ideas? I tried various requeries, refreshes and resyncs, but none have proven successful to date.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Set Current Record In A Datagrid.
Greeting All,
I am stuck and need your help.
I have a datagrid that retrieve data from a db thru an ADO recordset.
The problem is that after I change a value in a cell and click the Save button then the change get save in the db. Right after I click the Save button, if I change my mind and go back to that cell right away to change to a different value then click Save, the change does not get saved.
But if I click other row then come back to the row I changed before, then I can change the value and save sucessfully.

Please let me know if I miss something.

Thanks,
ConKi.

Ado /Datagrid Current Record Number
Somebody help pls..!!!
How will I know the current record number in an ADODC recordset output in DataGrid control?
It seems there is no property for that..
Thanks for any helping hands

Cecile


The more u read, the more u do not know

How To Locate The Current Record Position In Datagrid.
Hi,

I m displaying a records from one table in Datagrid. I want to display the record on another form, on which user clicks.

Can somebody help me on this. Thanks in advance for your kind help.

Gill

Make A Record In Datagrid Becomes Current When Clicked.
Greeting All,

I have a datagrid that retrieves data from a db thru an ADO recordset. My question is when I click a row, how can I set that row to be the current record of the recordset so that after I change a value of a cell in that row, that change can be saved in the db.

Thank you,
ConKi.

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

Retrieving Autonumber From New Record
Hi all,
I have just upgraded from DAO (yuk) to ADO (yum - apparently!) and have also changed from MS Access to MSDE.
Previously when adding a new record to a table with an autonumber field I could retrieve the pk as I added the new record. However I can't seem to do that with the ado/sql.

This is my new 'add to table' command

Code:
Db.Execute ("Insert Into Clients (Surname, First) & _
Values('" & txtSurname.text & "','" & txtFirstName.text & "')")
and this was my old one:

Code:
Set RsContactDetails = Db.OpenRecordset("PersonalDetails", dbOpenDynaset)

With RsContactDetails

.AddNew
StaffID = .Fields("StaffID").Value 'This retrieved the autonumber fields new value
.Fields("Surname").Value = sSurname
.Fields("First").Value = sFirstName
..................

Is there an easy way to do this using ADO/SQL?

Autonumber In Datagrid
How to generate number automatically in datagrid.
I have Itemcode, itemname, qty, rate, amount and remarks. when i want to insert a new record through datagrid, the itemcode should generate automatically and should display on datagrid1.columns(0).text, and other records user can enter. when user enters to next row, the itemcode should be +1 of previous rows in datagrid1.columns(0).text and so on.

Please help me to generate number automatically on datagrid.

i will wait for your reply on nitin@alsahel1.com

thanks & regards,
Nitin

Obtaining Autonumber When Adding A New Record
Hi all,

I'm connecting to a PostgreSQL db through ADO, and stumbled across a question. I have a table with an ID column that is an autonumbering sequence. When I perform an INSERT command to insert a new record in the table, I add data to all fields but the sequencing field (since it advances itself when the new record is commited).

Is there an easy way of knowing the sequence number that was created for that new row? Currently, I'm calling the nextval() function before adding the new row, and then adding the row, but it seems to me that this can lead to concurrency problems with a multi-connection database. eg, someone adds a record in the table after I obtain my nextval() but before I add my record.

Any help would be greatly appreciated.

Cheers!
-PJ

Selecting From Record Sheet Where Value Is An Autonumber
Hi, i am using the below code


rs.Open "select * from Customer where ID= '" & txtID.Text & "'", Conn, adOpenKeyset, adLockOptimistic

and it works fine, providing the values in ID (access database) are "text", if i put them as "autonumber", i get an error????

Any ideas??

Thanks

Andrew

Update Single Record With Ado - Autonumber
Hello!

I have a MSHFlexgrid, and when the users click it the curren record is selected, and the different fields moved into textboxes.

One of the fields is an Access Autonumber field, and not visible to the users.

The thought is to let the user update the record, and then click on an "Update"-button to update that specific record.

How can I do this with ado?

I have the functionallity to add a record, but I think the Autonumber might give me some problems with the update as the autonumber field is not updateable....

Do I have to delete the old record and add a new one, or can I edit the old one?


noccy

Help: Query Next Autonumber, Then Insert Record
Hey gang,

In my VBA I will need to get the next unique ID from the database (MSAccess autonumber) and then insert my values. This is because I will need the ID to update the same record at a later time. Because I could possibly have more than one user inserting at the same time, I cannot use the lastrow feature and add one to the number. Does anyone have any ideas on how to manage this?

I appreciate the help!

Thanks,

LS

Open Source Opens Doors

Adding Record With Autonumber Field In SQL
Im adding new record in my SQL table with an autonumber field, but when i use the rs.update method it says that recid is null. Recid is the autonumber field in my table. Isnt it should be automatically generated and you dont need to put values in it? What is the reason for that error?

Thanks

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

How To Show A Record With The Largest Number In An Autonumber Field?
In a database table, I have a primary key field called "Sequence" using autonumber. In a datagrid of VB6, how can I filter out all records and only show the record with the largest number of "Sequence"?

Can I use the adodc1.recordsource = "SELECT * FROM table1 WHERE Sequence = ..." How can I complete this statement?

Datagrid Autonumber Refresh Adodc Connection
I have table from access2k database with vb6 ide it working fine, datagrid
bind to adodc connection is success, now I want to change field "nonota"
from number to autonumber datatype, but it come out with error in a call
detail.

run time error
methode 'refresh' of object adodc fail

line adodc1.refresh

my code like this:

VB Code:
Sub Detail()Dim msql As String 'to display records in Data Gridmsql = "select KodeBarang,NamaBarang," & _    " HargaJual,Jumlah, Total" & _    " From tbNotaJualDetail " & _    " Where NoNota='" & txtnota.Text & "'" Adodc1.RecordSource = msqlAdodc1.Refresh 'error here dgdetail.Refresh End Sub


hope some one can help
thanks in advance

Access: Create A Memo Linked To Record's Non Existing AutoNumber Field - Got That?
Hi - I'm a newbie at VB, have been asked to create a small Access Database...

In one of the forms, basically what I need to do is to create a memo field, which is linked to other fields in the same form by a default AutoNumber. The problem is that when I am entering data into this memo field, the AutoNumber doesn't yet exist, since the record hasn't been actually created - and therefore, when I exit the memo, all the information is lost because since the AutoNumber didn't exist when I was typing the memo, now the memo is not linked to anything, so it gets lost. Of course, once I click out of the form and the record creates itself, I can go back and re-edit the memo field, and then it gets stored properly.

I have thought of a few workarounds, but nothing that I liked... Any help, please??

Thanks

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

Current Record
Hello

i have this form on access 97 that i use to edit data in one table......in this form i have combo boxes, txtboxes etc.. that i use to show and edit the information of the table ....... my question is the following...i want to edit data that i'm not display in my form such as the creation date of the record...this information is stored in the same table...but i don't need to show it ...so how can i call to the current recordset to save this information in a specific field

Table name tblaltas
field name creadate

i hope someone can help
Thanks in advance

No Current Record
Hi,

I have the following code:

Code:
Private Sub Submit_Forms()

Dim i As Long
Dim MtstN, FtstN
Dim MyDB, RS, lngRSCount, lngStartValue
Dim MHP, FHP, MCP, FCP

'This code will set the timer defined in Sub sSleep
Const cTIME = 3000 'in MilliSeconds
Const clessTIME = 500

'This is the beginning
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set RS = MyDB.OpenRecordset("2007 Football Registration",
dbOpenTable, dbReadOnly)
lngRSCount = RS.RecordCount
RS.MoveLast
RS.MoveFirst
'Decide where you want to start
lngStartValue = InputBox("On which record would you like to
begin?", "Starting Participant", 1)
With RS
If .BOF = True And .EOF = True Then
MsgBox "This recordset is empty"
Else
.MoveLast
End If
End With
try = MsgBox("Number of Records = " & RS.RecordCount, vbOKOnly, "MSG")


RS.Move (lngStartValue - 1)
'cTIME = 5000
'Call sSleep(cTIME)

ForC = RS.Fields("Football/Cheer")
FstN = RS.Fields("First Name").Value
LstN = RS.Fields("Last Name").Value
DOB = RS.Fields("Date of Birth").Value
If Mid(Mid(DOB, 1, 2), 2, 1) = "/" Then DOB = "0" & DOB
If Mid(DOB, 5, 1) = "/" Then DOB = Left(DOB, 3) & "0" & Right(DOB, 6)
MD = Left(DOB, 2)
DD = Mid(DOB, 4, 2)
YD = Right(DOB, 4)
WT = RS.Fields("Weight")
GPA = RS.Fields("GPA").Value
GPA = Left(GPA, 2)

'too much more to show, but problem is above.
Now, I get the 3021 Error every time, unless lngStartValue = 1. Highlighted at the line that begins ForC =... the first variable. My problem is that the BOF/EOF check shows records, and the msgBox shows records (199). Get to the first variable, "No Current Record". I feel like I have tried everything, to no avail.

Any help would be appreciated.

Thank You,

TB


Edit by Moderator:
Please use the [vb][/vb] tags when you post your code. Edit or reply to this post to see how.

Thank you.

No Current Record
Hi,

I have what I think should be a rather simple problem, but I can't find it. I have added a debug code and I'm not getting anything so I'm assuming that the loop code isn't working because it can't find any records to search. The correct form is coming up, but all fields are blank and when I click either next or previous buttons it says "No Current Record." I kept getting this error before, but after I added the code to check for BOF and EOF it allows me to execute this script, but not for it to work. I was orginally using the Find commands, but I was getting the same error so I tried using the loop. If I run formEditClass itself it works fine displaying all data and allowing me to freely move between records.


VB Code:
formEditClass.Show  If formEditClass.dbClassInfo.Recordset.BOF = True ThenformEditClass.dbClassInfo.Recordset.MoveNextElseIf formEditClass.dbClassInfo.Recordset.EOF = True ThenformEditClass.dbClassInfo.Recordset.MovePreviousEnd If Do Until formEditClass.dbClassInfo.Recordset.Fields("ClassName").Value = CSformEditClass.dbClassInfo.Recordset.MoveNextLoop

No Current Record
Hi all

When I open the form that has information in the database , there is no problems at all, but when I open the form with empty database this is the message I get. no current record.

Any one can help me to handl this problem please.

I will be highly appreciated.

Thank you

Mohammed

Getting The Current Record # Using ADO
I'm using Ado to access my database on an MS SQL 7.0 server. I want to know
as I am going through the recordset of a table what Record number I'm at.

Joel Foudy

Current Record
hello.

i just wanna ask is it possible to insert new record to a field and
yet that inserted record will be considered as ist record.

ex. if field 1 has 5 records. and field2 has 0 record.
then i will try to addnew or insert a record to field2.
normally , the inserted record will be considered as record6 of field2.
leaving field2 record 1- 5 as blank.

can somebody please tell me how to do this?
thanks,

anna

Current Record In ADO
Is there a way to find out which record I'm currently looking at in an ADO recordset?

For example, after a series of .MOVENEXT commands in a recordset, I want to know which record out of .RECORDCOUNT I'm looking at.

Thanks,
Yazster


Current Record Row
Hello!

Is there a function (such as recno() in other languages)to get the current record row of a table? I need to save to a variable this current record row so that I can use it later. Thanks in advance!

Get The Record Of Current Date!!!
Table Name = Calendar

CalendarDate Year Workweek Workday
............... ....... ...... ......
30/12/2004 2004 12 4
31/12/2004 2004 12 5
01/01/2005 2005 12 6
02/01/2005 2005 1 0
03/01/2005 2005 1 1
04/01/2005 2005 1 2
05/01/2005 2005 1 3
06/01/2005 2005 1 4
07/01/2005 2005 1 5
08/01/2005 2005 1 6
09/01/2005 2005 2 0
10/01/2005 2005 2 1
11/01/2005 2005 2 2
12/01/2005 2005 2 3
13/01/2005 2005 2 4
14/01/2005 2005 2 5
and so on......
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''
Public Function myFunction ()
Dim rsCalendar As Recordset

Set rsCalendar = CurrentDb.OpenRecordset ("Calendar" , db_open_dynaset)

With rsCalendar

End With

rsCalendar.Close

End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''

I want to get the record of Date() which point to Today date . I want to get the row of record of the Maximum value in "Workweek" which is the last Workweek value. I want to move to the next 20 record. If EOF then take the last record based on the Workweek. If not EOF then get the current record. What should i do?
Thanks in advance


Regards,
bananatree

Current Record Lock
hi hope all is well

(i am using microsoft access 2000)
I have a form and also navigation buttons at the bottom of the form.. i would like to lock a current record after it is updated... so the user can not go and edit what has been inputted in the previous row..

can someone help me out please....

thanks in advance - sonia...

No Current Record Error
I have a Access 97 database, and am making a VB interface to add/delete/edit records. I have this one table (called TblResults) that has no records in it to begin with, but I want to add one through VB.

Before I add any records, the table is empty, but some of the fields have a 0 in them, because that was the default entry for the Default Value property. One such field is called MatchID.

I want VB to check to see if MatchID is 0, and if it is, add a new record which has Match ID 1, and then delete Match ID 0. If VB checks Match ID and it isnt 0, then I want to add a new record which has a Match ID of 1 more than the last record.

I entered in the following code:


Code:
With DatResults.Recordset
If !MatchID = "0" Then
.AddNew
!MatchID = "1"
.Update
.FindFirst "MatchID = 0"
.Delete
Else
.MoveLast
Dim LastID as integer
LastID = !MatchID
.AddNew
!MatchID = LastID + 1
.Update
End If
End With

However, I get a error that says No Current Record, and the If !MatchID = "0" Then line is selected as the error line. I think this is because since the table is empty, it cant check to see what is in the field MatchID.

How can I check to see if the table is empty (or MatchID = 0) without encountering an error?

No Current Record Error
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:


Code:
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
addrs.MoveLast
count = Val(addrs.Fields("QuoteNo"))
'MsgBox count
addrs.AddNew

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

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

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

addrs.Close

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

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

addrs.Close
addcn.Close


'MsgBox addrs.RecordCount

Form1.Text63 = count + 1


Unload Form4

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

Form1.Show




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





Code:


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
'Data1.Recordset.MoveFirst
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.

No Current Record Message
I have a delete procedure which I have included a findfirst method in. Now an error comes up in this procedure stating

"No Current Record"

Have I missed something from the findfirst?? or is the loop incorrect?

The last line in the code is where the error occurs:

Dim matflag, matchdel, srchdel As String
'search for match
matflag = ""
matchdel = cbodeletepart.Text
srchdel = "Ryco_part = '" & matchdel & "'"
With fordpal
.FindFirst srchdel
If .NoMatch = True Then
matflag = ""
Else
matflag = "valid"
End If
End With
If matflag = "" Then
MsgBox "Please select a part from the list"
cbodeletepart.SetFocus
Else
parttodel = cbodeletepart.Text
ques = MsgBox("Are you sure you want to delete " & parttodel, vbYesNo)
If ques = vbYes Then
fordpal.MoveFirst
Do Until founddel = "yes"
If parttodel = fordpal![ryco_part] Then

Use Current Record In A New Form
Is there a way to select a record with one form then open another form with the selected record from the previous form set as the current record in the second form.
The problem is when opening a second form the current record is always set to the first record in the table.

Delete Current Record
Hello I would like to know how I can delete the current record in a recordset. I am using Access as database.

Dim RSone As Recordset

Set RSone = New ADODB.Recordset

With RSone
.CursorLocation = adUseServer
.CursorType = adOpenStatic
.LockType = adLockOptimistic
End With

strSQL = "SELECT * FROM HoraireBak ORDER BY DateVente"

Call CopyTable

Set RSone = Cn.Execute(strSQL)

'Some operations on the record


RSone.Delete <----------- Causes Error


I get the error '3251': Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.

Anybody has an idea to help me out please.

Thank you.

Sincerely,

Mark

Recordset Current Record?
I am using Access 2000. I am dealing with a recordset and want to know what the current record is, so that the navigation buttons can function properly. Either that or I need to know one record before BOF or EOF occurs.

I know there is a way to use the recordsetclone property of a form to do this, and possibly a way to clone the entire record set and accomplish the same thing, but I am using an unbound form, so the first option won't work, and I will be dealing with large numbers of records (up to 1 million), so I don't want to just make a clone of the whole recordset because I am worried about memory.

Basically, to sum it up, is there any way to know which record I'm at using just the 1 recordset that I am working with, sort of like a CurrentRecord property? I know this may seem like a newbie question but I haven't touched vb in about 6 months, so I apologize in advance.

ADO Update Current Record
Hello,

I am changing an old app from dao to ado. MS Access and using


Code:
Set conn = New ADODB.Connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0 "
conn.Open (App.Path & "work.mdb")
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "PartsInventory", conn, adOpenDynamic, adLockOptimistic, adCmdTable



I have a previous, next, new and update button. the update may have a logic issue cause I use it to save a new record and update a current record depending what the command buttons caption. see update button code


Code:
Private Sub Update_Click()


If Text2 = "" Then
MsgBox "The Inventory Item Name field is blank. If you don't want to create a new record click Cancel.", vbInformation, "Empty Field"
Text2.SetFocus
Exit Sub
End If

If Text1 = "" Then
MsgBox "The Quantity field is blank. If you don't want to create a new record click Cancel.", vbInformation, "Empty Field"
Text1.SetFocus
Exit Sub
End If

rs.Requery

If Command1.Caption = "Cancel" Then
With rs
.AddNew 'adding new record
.Fields("PartName") = Text2.Text
.Fields("Quantity") = Text1.Text

.Update 'this updates the recordset etc.
End With

Command1.Caption = "Add New"
Command2.Enabled = True ' disable delete button

ElseIf Command1.Caption = "Add New" Then
Command2.Enabled = True ' enable delete button


conn.Execute "UPDATE PartsInventory SET PartName ='" & Text2 & "' , Quantity='" & Text1 & "'" 'since quantity is a numberic field then there isnt the extra "' around it

End If


Text3.SetFocus


End Sub


the new record button turns to cancel when clicked for making new records. That button if not making new stays as "add New" so this means you are just updating a current record. I need my execute statement to update the current record. the table only has two fields part name and quantity. Current statement makes all records the same as whatever was in the current record.

Locate The Current Record
Hi, I have coding like this, and it updates the all rows in the table , but i wanted to restrict it to only the current record, please help on how to locate the current record and do the update . Thanks.

Set db = CurrentDb()

Set rst = db.OpenRecordset("Table1", dbOpenDynaset)

Do While Not rst.EOF

stScode = rst![SCode]
stLcode = rst![LCode]


If Not IsNumeric(stLcode) Then

stsql2 = "update lTable1 set errormsg='Numeric Value error in Lcode' "

DoCmd.RunSQL (stsql2)

Exit Sub

End If


rst.MoveNext
Loop

Problem With Current Record
Hi all..may i know how to avoid this error during add new data into Database.

"Either BOF or EOF is True,or the current record has been deleted.
Requested operation requires a current record."

I'm so wonder..sometimes it will give me this error and sometimes not..

Thanks

Update Record And Add Value To Current Value
hi,
i want to update a record like:

"update produtos set stock='10' Where ID=( " 1 )

but i want add the current value to the new value for example
the current record have 2 now i want add 10 them the record will have 12
i try this
"update produtos set stock+'10' Where ID=( " 1 )
but this dont work, i already see this right function in other place but i dont remember where i know that is possible any one know the right sintax?
thanks for the help
bruno

Update Current Record
Hi

I have a label which contains an ID now what I want to do is
update the current record if the label contains a value and if not
insert a row....

The code related to the condition is below

VB Code:
If (lblScaleEventID > 0) Or (ObjRSprodidvalues.EOF) Then        ObjRSprodidvalues.MovePrevious        ObjRSprodidvalues.Update     ElseIf (ObjRSprodidvalues.BOF) Then            Load frmvoidopid            frmvoidopid.Show vbModal           Else            ObjRSprodidvalues.MoveLast      End If       lblScaleEventID = ObjRSprodidvalues.Fields(0).Value


I receive an error ' EOF or BOF is true' or record is deleted...

Thanks for your help

Print Current Record
I finally got something workin in crystal report version 9. So my report has been created etc etc. But heres the problem Im having...it displays all the records in the database. I just want to run a print out of the report based on a user entering an ID number...is there a way to do this.

For instance a user is looking at ID # 200..and he wants to print out this record. When I run the report currently it shows all the records in the database...but all I want the printout to do is print ID #200.

Thanks,
Jon

Display Current Record??
I am using the ADO Data Control with access, i have a label where i want it to when the user goes from record 1 to record 2. Basically i wana be able to show the record that the user is on. Is there a way i can do it. I tried with alot of the commands but nothing seems to work

so something like this



You are on record [3] from [5]


Thx for you help.

Showing No Current Record ?
To,


I hope you will clear this doubt.

I want to enter names in the database using textbox.
if it is a first name it should update.if it is a second name which is not
similar to the first that record should be updated otherwise it should be
deleted.

The problem iam getting is not updating new record showing error has"No
current record"


my code:

Private Sub Cmd_updateClick()
Dim WS As Workspace
Dim DB As Database
Dim RS, RSL As Recordset
Dim E As String
Dim I As Integer
Set WS = DBEngine.Workspaces(0)
Set DB = WS.OpenDatabase("C:WINDOWSPATS.MDB")
Set RS = DB.OpenRecordset("EMP", dbOpenDynaset)








E = "select ENAME FROM EMP WHERE ENAME='" & Text1.Text & "'"
Set RSL = DB.OpenRecordset(E, dbOpenDynaset)
RSL.MoveLast
If I = 1 Then
Data1.Recordset.Update
Else
Data1.Recordset.Delete
End If
End Sub

Private Sub Cmd_addnewClick()
Data1.Recordset.AddNew
Text1.Text = " "
Text1.SetFocus
End Sub



Thanks.
brushindia@yahoo.com

Help!!! How Do You Find Current Record Value?
Newbie Here)I have an access database that I am using in VB. I need to return the value of the access database ID# to the program. In other words... I have 30 records, which are actually questions. The program needs to know which question or (Record) is selected. In access, the ID field is set to autonumber and tells which record is being viewed.

How do I do this in VB. I have exhausted my books. They all say how to move to previous, last, next, first, etc., but do not discuss how to show the current record ID.

Is it something like...

dim CurrentRecord as variant
CurrentRecord = data1.recordset.fields("Id")

Trying to figure out which record the database is looking at. Is it record 1 of 30 or record 26 of 30. How do I return this value to my program????

Please offer help.

Thanks,
Sal

View Current Record..
Does anyone know if there is a way to write a record to a table, through a form then hit a command button that writes to the table and have it automatically pop a message box or another form or something that would show me the record number (created automatically) of the entry?

Currently, I fill in the form and hit the "update" command with the following code. It doesn't "do" anything per say, except write to the table.... my problem is that I need to know the number it assigns to the record instantaneously. Any ideas anyone?

Private Sub cmdAdd_Click()
On Error GoTo AddErr
datPrimaryRS.Recordset.AddNew
frmSort.Show
Exit Sub
AddErr:
MsgBox Err.Description
End Sub

Kristin

BACKCOLOR OF CURRENT RECORD
Hi All,

How do I change the back color of the current record in a datagrid as I move from one record to the other.

Any help/code would be appreciated.

Thanks.

Emmanuel.

Print Current Record???
Hi everyone, any help much appreciated.
I have a form in VB6, all items in the form are linked to an ADO, i want to insert a print function to the form which will print the current record displayed, the record itself is saved an an Access DB.
At current i have no code, i have created a report in Access which will display the records, how ever it displays all the records and each record is on a seperate page, im afraid that adding a print function with this will have it print out 298 pages when i only want the one im viewing in my VB program...
Any help with this will be very much appreciated

To Know The Current Record Number
i want a label to write the current record number on my application. is there any function for that? thanks

How To Printout Current Record.
Hi friend,

I have a question about how to print out current record? I used Ms access to create a table which is bugsheet and I use VB to create the interface. after I enter the record. I want to print out only the current record that include the bugID. programmer, describtion..... Also, I hope the printout looks like .doc file.(see attachment)
how can I do it?

thank you

How Can I Update The Current Record ADO
Hello
dear
i am working on the Database but now these day i am facing probelm of Updating the Current record through ADO
i enter the fellowing code but when i exectue i recive an error
i am using UDL and jet 4.0 provider
how can i solve this problem i shall be very thankful to all of you

dim cn as Adodb.connection
Dim rs as ADODB.Recordset
dim cmdup as adodb.commad
dim updateP as adodb.parameter
dim Sqlup as string
set cn = new adobe.connection
cn.connectionstring = "file name = d:myudl.udl"
cn.open

set cmdup = new adodb.command
cmduup.activeconnection = cn
sql = "select * from Emp"
sql = sql &"where empno = ?"
set updateP = cmdup.parameter(,adinteger,input,3)
cmdup.parameter.append updateP
set rs = new adodb.recordset
rs = cmdup.execute

rs!name = txtname.text
rs.update
there are some mistakes in code because at that time i am working on the Computer in which there is no VB
ok sorry for that mistakes


Tamoor Ahmad
OCP DBA

No Current Record Error
Hi,

   When I try to do a select statement by opening a record set I keep getting a error that say "No current record". I am not sure why that's happening. Below is the code. Any help will be appreciated. Thanks

Code:
strFullName = Me.txtFullName.Value

strSQL = CurrentDb.OpenRecordset("SELECT FullName from tblClient where FullName = '" & strFullName & "' ").Fields(0)

If strSQL = Me.txtFullName.Value Then
MsgBox "duplicate value"
end if




Edited by - str50 on 5/1/2008 5:17:10 AM

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