Results 1 to 40 of 67

Thread: Save to database.. Please help

Threaded View

  1. #1

    Thread Starter
    Banned
    Join Date
    May 2014
    Location
    OH
    Posts
    459

    Question Save to database.. Please help

    I have a form with 3 textboxes, combo1, and 5 option buttons, what i would like to do is save the info into a database.
    Inside the database there is 7 fields - but for now i would like to just save 5 to the database:

    Name | Qty | Status | Type | Spice


    i have a module called "ModData" and in it is the following, but i really don't know how to use it..

    Code:
    Public db As Database
    Public rs As Recordset
    Public ws As Workspace
    
    Public Function InitDB(TableName As String, DataFile As String, DataIndex As String)
    Set ws = DBEngine.Workspaces(0)
    Set db = ws.OpenDatabase(App.Path & "\" & DataFile)
    Set rs = db.OpenRecordset(TableName, dbOpenTable)
    rs.Index = DataIndex
    End Function
    
    Public Function SelectData(TableName As String, TableCol As String, TheData As String)
    Set rs = db.OpenRecordset("SELECT * FROM " & TableName & " WHERE " & TableCol & "='" & Replace$(TheData, "'", "''") & "'")
    End Function
    but i have seen it used to save data into a database like:

    Code:
    rs.AddNew
    rs("Game Name") = Text1
    rs("Company") = Text2
    rs("Year") = Text3
    rs("Cartridge ID") = Text4
    rs("Rarity") = Combo1.Text
    rs("Own") = Text5
    rs("Qty") = Text6
    rs("Notes") = Text7
    rs("Value") = Text8
    rs("Label") = Text9
    rs.Update
    Last edited by elRuffsta; Sep 15th, 2014 at 11:05 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width