Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Texbox, combobox data

Status
Not open for further replies.

conceal

Technical User
Apr 1, 2007
14
NL
Hello,

In my database I would like to make my own forms with my own design. In this design I've put several unbound comboxes and textboxes to type certain data in. When a form is filled in completely, there is a commandbutton which should make sure that all the data in the several comboboxes and textboxes is written away to one or more cells in tables. I just don't know how I should do this. I've tried the expression builder, but no result. I would like to use Visual Basic code, but don't know how I can get the data to the tables. Can anybody help me? Thanks for your effort!

Greetings,
Maik
 
Are looking for an unbound form? Why you need a hurdle when access is straight & easy for bound forms?
any how... here is a sample to update table from an unbound form. You need to have proper error checking and data validation before you proceed to update.
Code:
Private Sub cmdSave_Click()
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim strSQL As String
    Set cn = CurrentProject.Connection
    Set rs = New ADODB.Recordset
    
    strSQL = "SELECT * FROM YourTableName"
    rs.Open strSQL, cn, adOpenKeyset, adLockOptimistic
    
    rs.AddNew
    
    rs("FieldName1") = Me.TextBox1.Value
    rs("FieldName2") = Me.TextBox2.Value
    rs("FieldName3") = Me.TextBox3.Value
    
    rs.Update
    
    rs.Close
    cn.Close
    Set rs = Nothing
    Set cn = Nothing
End Sub


________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top