perezm
asked on
Record Restriction
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.
Any assistance would be appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi
in place of RecordCount Condition please modify this
if recCnt.RecordCount > 25 then
End 'Close the Application
end if
in place of RecordCount Condition please modify this
if recCnt.RecordCount > 25 then
End 'Close the Application
end if
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
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
ASKER
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.
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.
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,adOpenDynami
if recCnt.RecordCount <> 25 then
else
Msgbox " Your Demo Version "
End 'Close The Application
end if
End Sub