|
-
Mar 6th, 2005, 10:00 PM
#1
Thread Starter
Member
VBA in Access 2003 - Insert into Database From Form
Hi all,
I'm new to VBA, but have been working with VB for sometime now. I have a very basic question that I would have no trouble with in VB.Net, but here it goes. I am trying to insert data from a form that I made into a table in the database. I've made the query for the insert with all of the parameters outlined. WHen I press the submit button I want it to send the corresponding text box values to the query, so it will add to the table. The only problem is I really am having some troubles. This is as far as I could go
VB Code:
Dim db As Database
Dim qry As QueryDef
Const strQueryName = "Camp_Create_InsertInto_Student_Info"
Set db = CurrentDb()
qry.Parameters("@Student_Fname") = FirstName.Value
qry.Parameters("@Student_Lname") = LastName.Value
qry.Parameters("@Student_Age") = Age.Value
qry.Parameters("@Student_DOB") = DOB.Value
qry.Parameters("@Student_GardianName") = Gardian.Value
qry.Parameters("@Student_Address") = Address.Value
qry.Parameters("@Student_Apt") = Apt.Value
qry.Parameters("@Student_City") = City1.Value
qry.Parameters("@Student_State") = State.Value
qry.Parameters("@Student_Zip") = Zip.Value
qry.Parameters("@Student_HomePhone") = Phone.Value
qry.Close
db.Close
It gave me problems. This code is in the onClick event procedure for the button on the form. I'm very lost and could really use some help with this simple but important part of developing something within Access. Please help.
Cran56
-
Mar 6th, 2005, 10:30 PM
#2
Re: VBA in Access 2003 - Insert into Database From Form
What error messages are you getting? Can you run the Camp_Create_InsertInto_Student_Info query
manually successfully? Place a breakpoint in the Private Sub Command1_Click procedure. Then run the form and
enter your values. When you click on the button you can step through the code to verify the values are valid
for the table data types, etc.
You dont want to use bound controls? May be easier depending on what your needs are.
VBA is almost exactly the same as VB
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|