Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 1st, 2006, 09:37 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default add new row to a table

Hey guys,

I'm having a problem adding a new row of information to my table.
I've been switching a few things around, but I keep getting different errors.
My form takes 2 entries in textboxes (txtDesign2,JITL)
The table has 3 fields
I'm trying to make a new row at the bottom of the table with the
2 entries in their respective fields and set the other field to "Y"
The problem seems to be at mydb.OpenRecordset.
This is the code.

Private Sub btnSave_Click()
Dim mydb As Database
Dim mytable As Recordset
Dim route As String
Dim Design As String

route = Me![JITL]
Design = Me![txtDesign2]

If route <> "20" And route <> "40" Then
    MsgBox """Invalid JITL...Please Re-Enter""", vbOKOnly, ""
Else
    DoCmd.SetWarnings False
    Set mydb = (DBEngine.Workspaces(0).Databases(0))
    Set mytable = mydb.OpenRecordset("T_new_thermo_order", dbOpenDynaset)
    mytable.AddNew
    mytable("dsn_nbr") = Me![txtDesign2]
    mytable("jitl") = Me![JITL]
    mytable("order_typ") = "Y"
    mytable.Update
    mytable.Close
    mydb.Close
    DoCmd.Close acForm, "frm_New Order"

End If
End Sub


Thanks for any help,
Dave

 
Old June 1st, 2006, 11:04 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind.
I found what I needed on another post.

Thanks Beth Moffitt

-Dave






Similar Threads
Thread Thread Starter Forum Replies Last Post
add row with textboxes in a table imnk2 ASP.NET 1.0 and 1.1 Basics 1 June 25th, 2007 04:53 PM
UPDATING 1 row with another row in same table rit01 SQL Server 2000 3 February 19th, 2006 08:55 AM
How to add Row dynamicaly in Datagrid msbsam ASP.NET 1.0 and 1.1 Basics 2 December 7th, 2005 08:12 PM
use vba to add a row to datasheet TerryAutomation Access VBA 2 July 11th, 2005 01:07 PM
add row no automatically Jane SQL Language 9 June 28th, 2004 02:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.