Solved

automation error in exe files

Posted on 2002-05-10
2
135 Views
Last Modified: 2010-05-02
I use the following code to generate automatic numbers in my form. The code works well within VB. When the project is made as exe file, it shows "Automation Error" when there is no records in the database. It makes no problems when there are some records already existing in the concerned table. I am using MS Access as the back end.

Public Sub proNewNumberGeneration()
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset
Dim strnnsql As String
strnnsql = "select max(ReciptNo) from CashRecipts"
rs2.Open strnnsql, adocn
adocn.Execute strnnsql
If rs2(0) > 0 Then
                q = "CR"
                c = Mid(rs2(0), 3, 6)
                d = Format(Val(c) + 1, "0000")
                cboReceiptno.Text = q & d
Else
              cboReceiptno.Text = "CR0001"

End If
End Sub

0
Comment
Question by:r_venkatadhri
[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
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 7001633
Add a test for .eof

If rs2.Eof Then
  cboReceiptNo.Text = "CR0001"
Else
  If rs2(0) > 0 Then
    'continue with the rest of your code
End If

This will ensure that if there are no records you get the default.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7001931
good!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

624 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