Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Database entry

Posted on 2003-02-24
3
Medium Priority
?
167 Views
Last Modified: 2010-05-01
Private Sub cmdAdd_Click()
CompDate = mskDate.Text
CompStart = mskStart.Text
CompFinish = mskFinish.Text

Me.AdoNewComp.Refresh

With AdoNewComp.Recordset
!Sponsor_of_Comp = txtSponsor
!Date = CompDate
!Type_1 = cmbType1
!Type_2 = cmbType2
!Type_3 = cmbType3
!No_of_Holes = cmbHoles
!Markers = cmbMarkers
!Start_Time = CompStart
!Finish_Time = CompFinish
.Update
End With


Any idea whats wrong with this code, i get the multiple step operation error?



0
Comment
Question by:iregan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:kshore
ID: 8009794
What about adding '.Text' after after the references to the combo box value, as follows:

Private Sub cmdAdd_Click()
CompDate = mskDate.Text
CompStart = mskStart.Text
CompFinish = mskFinish.Text

Me.AdoNewComp.Refresh

With AdoNewComp.Recordset
!Sponsor_of_Comp = txtSponsor
!Date = CompDate
!Type_1 = cmbType1.Text
!Type_2 = cmbType2.Text
!Type_3 = cmbType3.Text
!No_of_Holes = cmbHoles.Text
!Markers = cmbMarkers.Text
!Start_Time = CompStart
!Finish_Time = CompFinish
.Update
End With
0
 
LVL 3

Accepted Solution

by:
QJohnson earned 400 total points
ID: 8009906
You don't offer the symptoms of the problem.  Something not happening that should?  Something happening that shouldn't?

Are you trying to create a new record or edit existing here?

If you are adding, you need the .AddNew method call before you make your field changes, otherwise it will try and make these changes to the current record.  This will, of course, generate a run-time error for you if there IS NO current record (I think it's ADO error 21) for it to work with.

Also... you should probably adopt the rule most of us live with and NEVER use reserved words for field names.  Why give the compiler a chance to be really confused?  In this case, that means change the name of the Date field to something more descriptive like CompDate, perhaps.  If you use the type prefixes in the name, you are protected from this issue automatically of course (because your field would be named dtmDate instead of Date).  But I acknowledge that many developers don't use those conventions in field names even when they do with variable names.  

[This is a shame, in my opinion.  With the Caption property available to us in JET, the user doesn't need to see our real field name anyway.  Of course, if you're not using JET, this is not much help <g>]

HTH,

QJ
0
 

Author Comment

by:iregan
ID: 8016372
Got the problem solved but Ill give u the points
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question