?
Solved

Record Restriction

Posted on 2002-03-31
5
Medium Priority
?
190 Views
Last Modified: 2010-05-02
I am using Visual Basic 6 with MS Access 97 at the back end.  I am trying to set up a demo program and would like to restrict, to 25, the number of records that on can be added to any table in the database.

Any assistance would be appreciated.
0
Comment
Question by:perezm
[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
5 Comments
 
LVL 3

Accepted Solution

by:
Bahnass earned 200 total points
ID: 6909451
if u r using recordset  (ADO OR DAO) U will have a property called recordcount

check it before saving prevent saving if demo count exceeded

if U use adodc also in willmove  check if update record and record count axceeded ....
hope this helps
0
 

Expert Comment

by:talluri_28
ID: 6909678
hi

i am giving some code. i think it will be useful to u
if u r using ado tech
Public Sub RecCount()
    dim recCnt as new adodb.recordset
    if recCnt.state = adstateopen then recCnt.close
    recCnt.CursorLocation = adUseClient
    recCnt.Open "Select * from   TableName",cn,adOpenDynamic,adLockOptimistic
    if recCnt.RecordCount <> 25 then
    else
      Msgbox " Your Demo Version "
      End 'Close The Application
    end if
End Sub
0
 

Expert Comment

by:talluri_28
ID: 6909682
hi


in place of RecordCount Condition please modify this
if recCnt.RecordCount > 25 then

  End 'Close the Application
end if  
0
 
LVL 6

Expert Comment

by:MELeBlanc
ID: 6910108
Given that you're using ADO (if not then the code would need to be tweaked a bit ;)

Private Function DemoExceeded() As Boolean

    Dim strSQL As String
    Dim rsCount As ADODB.Recordset
   
    strSQL = "Select COUNT(*) From YourTableName"
   
    Set rsCount = objConn.Execute(strSQL)
   
    If rsCount(0) > 25 Then
        DemoExceeded = True
    Else
        DemoExceeded = False
    End If
   
    rsCount.Close
    Set rsCount = Nothing
   
End Function

Then just call this function before every insert into the dB and that will help you restrict it.

Hope it helped.

-M
0
 
LVL 1

Author Comment

by:perezm
ID: 7019844
I had already accepted this answer and graded it a long time ago.  I don't know why it wasn't processed.

Thanks for the help.  I should have figured this out,
but I guess I my logic was in limbo.

The answer is so obvious that I missed it.  

Again, thanks for the help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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
Course of the Month10 days, 19 hours left to enroll

770 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