Question:
in visual basic 6.0, how do i add information from text boxes to an access database using command buttons?
warrenrayson4abeer
2009-02-16 06:33:05 UTC
i would like to know how i can add a record to a table in microsoft access using the data in text boxes with the click of a command button. i am using an adodc to connect the form to the database and have read that i need to do some sort of adodc.recordset.addnew code, but this doesnt seem to work

other websites have told me that my code needs to resemble

adodc1.Recordset.AddNew
adodc1.Recordset.Fields(0) = Text1.Text
adodc1.Recordset.Fields(1) = Text2.Text
adodc1.Recordset.Fields(2) = Text3.Text
adodc1.Recordset.Update

and this did work at one point but now it is telling me that 'Object variable or With block variable not set'. what does this mean and how can i modify the code to get it to work again?

need any additional info please ask and thanks to anyone that can help me
Three answers:
Bacon
2009-02-16 11:39:11 UTC
I have always preferred to work directly with SQL statements, it has been more reliable for me in the past. The page below has some good sample code on how to do.
?
2016-10-06 09:28:31 UTC
First i'm assuming the concern isnt getting the observe checked, or using messagebox, yet getting yet another kind to load from you kind (?) There are slightly distinctive a thank you to try this in VB6 and until now, or VBA. out of your code i think of you attempt to try this in VB.internet. additionally, issues could be distinctive based regardless of in case you easily prefer to coach it as a communique, and additionally in case you have a toddler varieties and an MDI ecosystem. besides, attempt this (Given with out garantees!, yet demonstrates the fundamentals) '________________________ Public classification Form1 inner maximum WithEvents frmMain As frmMain 'The communique '_______________________________ inner maximum Sub btnScan_Click(ByVal sender As device.merchandise, ByVal e As device.EventArgs) Handles btnScan.click If txtName.textual content cloth = "" Then MessageBox.coach("Please enter a valid archive call.") go out Sub Else If txtName.textual content cloth = "MyWord" Then MessageBox.coach("Sorry, incorrect observe.") go out Sub Else frmMain = New frmMain frmMain .ShowDialog() 'do a little stuff after the kind closes end If end Sub '________________________________ inner maximum Sub frmMain_FormClosing(ByVal sender As merchandise, ByVal e As device.homestead windows.varieties.FormClosingEventArg... Handles frmMain.FormClosing 'capture the ultimate experience frmMain.Dispose() end Sub desire this works for you.
cooltut
2009-02-19 18:48:59 UTC
Follow these URLs. You will find the answer



http://visualbasic.freetutes.com/learn-vb6/lesson22.html

http://visualbasic.freetutes.com/learn-vb6-advanced/lesson8

http://visualbasic.freetutes.com/learn-vb6-advanced/lesson9


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...