|
-
Sep 23rd, 2007, 11:56 PM
#1
Thread Starter
Junior Member
Data1.Recordset.AddNew
hello all,.
i am working on a program that does add, delete, update and find, so far i managed with all except for add,
i have the below code:
Dim strBufferTaper As String
strBufferTaper = txttaper.Text
DataTaperCode.UpdateControls
DataTaperCode.Recordset.AddNew
txttaper.Text = strBufferTaper
DataTaperCode.Recordset.MoveNext
DataTaperCode.Recordset.AddNew
which works fine to add a new record to a table called Taper
how do i enhance this code to check for duplicate in the table before adding the new record, if the record already exist, give a message box, if not, then add the new record from the user input (txttaper.text)
please help
thank you in advance
-
Sep 24th, 2007, 05:14 AM
#2
Re: Data1.Recordset.AddNew
It would be easy enough using programming code, but I don't know of a way using a bound data control.
-
Sep 24th, 2007, 12:16 PM
#3
Thread Starter
Junior Member
Re: Data1.Recordset.AddNew
how do i use programming code, as you suggested, could you teach me?
-
Sep 24th, 2007, 01:30 PM
#4
Re: Data1.Recordset.AddNew
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Sep 24th, 2007, 01:33 PM
#5
Re: Data1.Recordset.AddNew
Once you are comfortable in connecting via code, we can take a look as using the SQL SELECT query to return a value from your database.
-
Sep 25th, 2007, 06:18 AM
#6
Thread Starter
Junior Member
Re: Data1.Recordset.AddNew
hi
i went through the tutorial.... could you show me on the sql part?
thanks
-
Sep 25th, 2007, 06:21 AM
#7
Re: Data1.Recordset.AddNew
-
Sep 25th, 2007, 10:03 AM
#8
Thread Starter
Junior Member
Re: Data1.Recordset.AddNew
hello
thanks for the sql tutorial, i managed on the below codes:
Set DB = OpenDatabase(App.Path & "\Project Light Speed.mdb")
SQL = "select * from [Taper_Code] where Taper_Code ='" & txttaper.Text & "'"
Set rs = DB.OpenRecordset(SQL)
SQL = "insert into Taper_Code (Taper_Code) " & _
"values ('" & txttaper.Text & "')"
DB.Execute SQL
How do i implement that after i select the record, if not found then do the insert part, else display a message box?
please help
-
Sep 25th, 2007, 10:11 AM
#9
Re: Data1.Recordset.AddNew
Code:
Set DB = OpenDatabase(App.Path & "\Project Light Speed.mdb")
SQL = "select * from [Taper_Code] where Taper_Code ='" & txttaper.Text & "'"
Set rs = DB.OpenRecordset(SQL)
If rs.RecordCount = 0 Then 'it does not exist
SQL = "insert into Taper_Code (Taper_Code) " & _
"values ('" & txttaper.Text & "')"
DB.Execute SQL
Else
MsgBox txttaper.text & " already exists in the database."
End If
-
Sep 25th, 2007, 11:26 AM
#10
Thread Starter
Junior Member
Re: Data1.Recordset.AddNew
hack,
Thank you so much for your help, that code works great.
joyce
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|