how to create save function
hi everyone..i'm newbie in vb 6 and i really need helps from u guys here.
Actually, i've 9 textboxes and 10 comboboxes in the form. what i want is when i enter Print button, the data will stored in database and in the same time it will go to new form. The link to new form is already successful. the problem now is how to create the save function??
here i paste my code.
Code:
Private Sub SaveData()
'conn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password ='999999';Data Source=(local);Initial Catalog =TGB"
Conn2.Open
cmd = "INSERT INTO DMF_ERP_TumTag(FactoryID, TTLineNo, DateTime, " _
& "BlockNo, GloveType, TTSize, Side, Color, Texture, Length, Thickness, " _
& "GloveWeight, BasWeight, BasBarCode, CompTankNo, BasketNo, TumblerNo, " _
& "TumblerBoyID, Supervisor)" _
& " VALUES ('" & cboFacId.Text & ", " & ComboBox1.Text & "," _
& " #" & txtDateTime.Text & "#, " & Text2.Text & ", " & cboGloveType & ", " & cboSize.Text & "," _
& " " & cboSide.Text & ", " & cboColour.Text & ", " & cboTexture.Text & ", " & cboLength & "," _
& " " & cboThickness.Text & ", " & Text3.Text & ", " & Text1.Text & ", " & txtBarcode.Text & "," _
& " " & Text4.Text & ", " & Text5.Text & ", " & Text6.Text & " , " & Text7.Text & ", " & Text8.Text & " ')"
rs.Open cmd, adOpenStatic, adLockReadOnly
Conn2.Execute cmd
Re: how to create save function
Re: how to create save function
Welcome to the forums :wave:
You don't need a Recordset for INSERT and UPDATE, only for SELECT. So it would go something like this:
Code:
Conn2.Open
Conn2.Execute "INSERT..."
Conn2.Close
However, it's quite unusual to create a new Connection in a sub-procedure. People usually use one that's global. Just a suggestion ;)
Re: how to create save function
thanx gavio..i'll try this first..
:P