Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 29th, 2003, 09:30 PM
NuStar NuStar is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 NuStar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to NuStar Send a message via Yahoo to NuStar
addnew help

I am trying to develp a small program that has access db in the background.

I type items in my form, hit "Save" and I get an error msg. I then hit the debug button, it takes me to rs.update

here is my code
Option Explicit
Dim db As Database
Dim rs As Recordset
Private Sub Form_Load()
Dim x
Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\homefirst.mdb")
Set rs = db.OpenRecordset("companyinfo")
End Sub
Private Sub cmdClear_Click()
'Clears the text in all the fields.

txtSalesTaxRate.Text = ""
cboSalesTaxState.Text = ""
cboPaymentTerms.Text = ""
txtInvoiceDes.Text = ""
txtPhone.Text = ""
textFAX.Text = ""
txtCompanyName.Text = ""
txtStreetZip.Text = ""
cboStreetState.Text = ""
txtStreetCity.Text = ""
txtZip.Text = ""
cboMailingState.Text = ""
txtMailingCity.Text = ""
txtMailingAddress.Text = ""
txtstreetAddress.Text = ""
txtEstimateDes.Text = ""

'Moves curser to top of form.
txtCompanyName.SetFocus


End Sub

Private Sub cmdExit_Click()
'Ends the program without saving.

End

End Sub


Private Sub cmdSave_Click()
'Set database
Set rs = db.OpenRecordset("companyinfo")

If txtSalesTaxRate.Text = "" Or _
cboSalesTaxState.Text = "" Or _
cboPaymentTerms.Text = "" Or _
txtInvoiceDes.Text = "" Or _
txtPhone.Text = "" Or _
txtFax.Text = "" Or _
txtCompanyName.Text = "" Or _
txtStreetZip.Text = "" Or _
cboStreetState.Text = "" Or _
txtStreetCity.Text = "" Or _
txtZip.Text = "" Or _
cboMailingState.Text = "" Or _
txtMailingCity.Text = "" Or _
txtMailingAddress.Text = "" Or _
txtstreetAddress.Text = "" Or _
txtEstimateDes.Text = "" Then
MsgBox "Please fill all the boxes."

Else
rs.AddNew
rs!SalesTaxRate = txtSalesTaxRate.Text
rs!SalesTaxState = cboSalesTaxState.Text
rs!DefaultPaymentTerms = cboPaymentTerms.Text
rs!DefaultInvoiceDescription = txtInvoiceDes.Text
rs!PhoneNumber = txtPhone.Text
rs!FaxNumber = txtFax.Text
rs!CompanyName = txtCompanyName.Text
rs!StreetZip = txtStreetZip.Text
rs!StreetState = cboStreetState.Text
rs!StreetCity = txtStreetCity.Text
rs!MailingZip = txtZip.Text
rs!MailingState = cboMailingState.Text
rs!MailingCity = txtMailingCity.Text
rs!MailingAddress = txtMailingAddress.Text
rs!StreetAddress = txtstreetAddress.Text
rs!DefaultEstimateDescription = txtEstimateDes.Text
rs.Update
End If
Unload Me
rs.Close
End Sub


I can be reached by AIM - nustartec
msn - URL
Y! - jmyers_nc

please help


jeff

Reply With Quote
  #2  
Old December 30th, 2003, 11:44 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,174 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 27 m 59 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
ok - I have a few problems here - 1. Are you doing this in VB6, or VBA? I've seen several people using the "Dim db as Database" syntax lately, and I would strongly suggest that you use traditional ADO if possible. 2. You have declared a module level recordset, and in form_load, you are opening that recordset. Then in your click event, you're opening it again. Is there a reason for this? I don't think that this is your problem, but I'm curious.

I would strongly suggest the former, however. ADO has methods of checking for errors and more detailed error messages.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > addnew help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway