Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6749055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:38:37+00:00 2026-05-26T12:38:37+00:00

Using VB6 I am saving the user the entry in the database. Code. rst.Open

  • 0

Using VB6

I am saving the user the entry in the database.

Code.

rst.Open "SELECT * FROM ShiftMaster WHERE Shift_Code = '" & Trim(txtCode.Text) & "'", adoPunching, adOpenDynamic, adLockBatchOptimistic
    If (rst.BOF And rst.EOF) Then
        rst.AddNew
    End If


    rst!Shift_Code = "" & txtCode.Text
    rst!Shift_Name = "" & txtName.Text
    rst!Start_Time = "" & Format(dtpFrom.Value, "HH:mm")
    rst!End_Time = "" & Format(dtpTo.Value, "HH:mm")
    rst.UpdateBatch
    rst.Requery
    rst.Close
    MsgBox "Data successfully saved.", vbInformation
    lvdvendor

The above code is working for saving, but if the user enter the same txtcode means it should modify the records, it should add new rows.

For Example

ID Value

001 200

If the user enter the same id in the textbox like 001 and user changed the value like 500 means it should chand only the value, It should add one more row with same id.

How to do this.

Need VB6 Code Help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:38:38+00:00Added an answer on May 26, 2026 at 12:38 pm

    How do you know which record you are poining to after doing the query? The answer is that you don’t so you need to move to the first record:

    rst.movefirst
    'then add new if no records exist:
    If (rst.BOF And rst.EOF) Then
        rst.AddNew
    End If
    

    One point to note though is that you may return more than one record when you do your query so in this way it will only update the first one it finds. You way want to consider using TOP 1 * so ensure you only retrieve 1 or 0 records.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using VB6 and Access 2003 Query Select Temp.* into NewTable from Temp Table Name
Using VB6 Code. CommonDialog1.DialogTitle = Open File CommonDialog1.Filter = *.* CommonDialog1.FilterIndex = 1 CommonDialog1.Flags
Using VB6 & Crystal Report 9. Need help with the VB6 code. When i
Using VB6, SQL Server 2000 I want to connect to others system database. Code:
AM querying an access database from vb6 using the following query INSERT INTO stock([i_name],[ref],[qty],[supplier_id])
AM querying an access database, selecting records from two tables, in vb6 using the
Using VB6 Code. Dim posn As Integer, i As Integer Dim fName As String
Using VB6 code Dim fso As FileSystemObject Dim TS As TextStream Dim TempS As
I'm using VB6 and trying to create a DAO recordset from an array of
Using VB6, how do I copy a file from another computer to my computer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.