Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

vb6 serial communication

Status
Not open for further replies.
update ms access data from vb6

hi
I have created a program to connect to a Access database and retrieve records from it using a recordset.
I am using the ADOBC.Recordset sort of connection.

I know how to add records, delete records however i dont know how to edit already existing records.

say i have a column called "STATUS" in the access table. when i click the command button i need to edit the value of the 5th row of the STATUS column to 3.

Anyhepls help me anyone
 
Update Method

Update a record set link from my previous post here
 
hi all
im doing a project with vb6 and acces.i need to add a new row of data to a table called table1. lets say when i enter a command button txtadd.text data shoud go to address column of the new row. how can i do this.pls help me. im using this code but it is giving me errors

ad1.Recordset.MoveLast
ad1.Recordset.MoveNext
ad1.Recordset.addnew("address")=txtadd.Text
ad1.Recordset.addnew("status")=txtstatus.Text

pls anyone help me with a sample code
thenx
 
What are the errors that it is giving?
 
it "says expected function or variable"
i there anything wrong with the following definition
"ad1.Recordset.addnew("address")=txtadd.Text" ?
thanx
 
Try something more along the lines of

Code:
Dim fieldsArray(1) As Variant
fieldsArray(0) = "intf"
fieldsArray(1) = "charf"
Dim values(1) As Variant
values(0) = 4
values(1) = "as"
rs.AddNew fieldsArray, values
rs.Update
 
thanx
this code is ok.by using this code new values are added to the first row of the table. but i need to add the new values to a new row, which is at the end of all data in the table.

ad1.Recordset.MoveLast
ad1.Recordset.MoveNext
ad1.Recordset.AddNew "bulb", cmbadd2.Text
ad1.Recordset.Update
i tried above code but it adds the new values to the first raw. how can i add them to a new row?
help pls
thanx
 
Maybe you need recordset.append as here
 
hi
thanx for the reply. i need a nother help
say i have a byte(ex:00110100). i need to the last six bits (110100) to be changed like 001011. which means lsb to msb. and msb to lsb and all other bits also change there position.pls help me with a code or method.
thanx
 
Ensure that you byte is in an unsigned variable and then use the not operator.
 
It's not very elegant but should work,
Code:
Function SwapBits(Number As Byte) As Byte
Dim Answer As Byte
    Answer = 0
    For x = 0 To 7
        Answer = Answer + ((Number \ (2 ^ x)) And 1) * (2 ^ (7 - x))
    Next x
    SwapBits = Answer
End Function

Edit, just noticed you only wanted it to work on the bottom 6 bits. To make it work that way, change the sevens (two of them) to fives.

Mike.
 
Last edited:
hi
im working with VB6 and access. i have a command button called "cmddelete". when i click this a row of access table should be deleted. the row has fields "bulb","status","type"when click the button all the fields are deleted. for that im using the following code

ad1.Recordset.Filter = "bulb = '" & dinningroom & "'"
ad1.Recordset.Fields("status").Value = Delete
ad1.Recordset.Fields("bulb").Value = Delete
ad1.Recordset.Fields("type").Value = Delete
ad1.Recordset.Update
ad1.Recordset.Filter = adFilterNone

This code works correctly and delete the entries of the row. but the problem is since the "dinning room" row is in the middle of the table after deleting there will be an empty row in the middle of the table. i need not to have empty rows. i need to shift the other entries one by one up after deleting the row. how can i do this. what should i add to this code?
pls help me
thanx
 
It's a (very) long time since I did any data base stuff in VB but I seem to remember you somehow selected the record and then did recordset.delete .

Mike.
 
Hi
i have a vb interface. i need to do a shedule task after a user specified time period.lets say i have a text box(txttime) to enter the time in milliseconds. when the user click the command button(cmdon), a timer should be enabled and after the specified time expires a massage should be displayed in the label (lblmsg). How can i do this. pls anyone help me with a sample code.
Thanx
 
Iish

Something like this should work:

Code:
Private Sub Command1_Click()
    myval = Text1.Text
    Timer1.Interval = myval
    Timer1.Enabled = True
End Sub

Private Sub Form_Load()
    Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
    Label1.Caption = "time expired"
    Timer1.Enabled = False
End Sub
 
Here you go,
Code:
Private Sub Command1_Click()
    If Val(Text1.Text) <> 0 Then
        Timer1.Interval = Val(Text1.Text)
        Timer1.Enabled = True
    End If
End Sub

Private Sub Timer1_Timer()
    If Form1.BackColor = &H8000000F Then
        Form1.BackColor = &HFF0000
    Else
        Form1.BackColor = &H8000000F
    End If
    Timer1.Enabled = False
End Sub

The above will turn the backgroud blue after the time in textbox1. I'll leave it for you to make it display a message.

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top