473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Access having 2 VBA connections to current db

I am trying to select all the chapters from the chapter table, and
then for each chapter instert a count of how many members are in that
chapter into another table.. Here is the code so far and I have marked
where the error occurs:

Dim Chapter, Month, Year, Count, EndMonth, EndYearAs Integer
Dim strSql, subStrSql As String
Dim rst, subrst, rsnew As New ADODB.Recordset

' This is just saying that the count should be over 2 months
Month = cbo_Month.Value
Year = txt_Year.Value

If Month < 11 Then
EndMonth = Month + 2
EndYear = Year
Else
EndMonth = Month - 10
EndYear = Year + 1
End If

'Setup the RegPrez2 Table
'----------------------------------------------------------

strSql = "Delete * from RegPrez2;"
CurrentDb.Execute strSql

strSql = "INSERT INTO RegPrez2 ( Chapter, Region, State, Category,
Descr )"
strSql = strSql & " SELECT DISTINCT Chapter.Chapter, Chapter.Region,
Chapter.State, Chapter.Category, Chapter.Descr FROM Chapter;"
CurrentDb.Execute strSql

'----------------------------------------------------------

strSql = "Select Chapter from RegPrez2;"

rsnew.Open strSql, CurrentProject.Connection

With rsnew
..MoveFirst
While Not .EOF

strSql = "SELECT Count(Member.MembNo) AS CurrentCount From
Member WHERE Member.Chapter = """
strSql = strSql & rsnew("Chapter") & """ AND Member.JoinDate <
Datevalue('" & EndMonth & "/01/" & EndYear & "');"

'It Bombs here with object expected I believe
rst.Open strSql, CurrentProject.Connection

subStrSql = "Update RegPrez2 Set CurrentCount = " &
rst("CurrentCount")
CurrentDb.Execute subStrSql
rst.Close
Set rst = Nothing

..MoveNext
Wend

End With
'---------------------------------------

Any help would be greatly appriciated. Thank you
Nov 12 '05 #1
1 1990
br*****@vt.edu (Brendan Ganning) wrote in
news:f7**************************@posting.google.c om:
I am trying to select all the chapters from the chapter table,
and then for each chapter instert a count of how many members
are in that chapter into another table.. Here is the code so
far and I have marked where the error occurs:

Dim Chapter, Month, Year, Count, EndMonth, EndYearAs Integer
Dim strSql, subStrSql As String
Dim rst, subrst, rsnew As New ADODB.Recordset
Any help would be greatly appriciated. Thank you

You have dim'ed rst and subrst as type variant.

You need to specify AS <TYPE> individually for each variable on a
line.

Dim Chapter as integer, Month as integer, , Year as integer, Count
as integer, EndMonth as integer, EndYear As Integer
Dim strSql as string, subStrSql As String
Dim rst as new adodb.revcordset, subrst as new adodb.recordset,
rsnew As New ADODB.Recordset

Bob Q.
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
5
by: elieli_132 | last post by:
Hi, My problem is the following: Made changes to code in form and closed the form. Now unable to open / design the form. - Tried copying and pasting - the new one does not open /display....
26
by: Dragon | last post by:
I have an Access 2003 .mde sitting on an SQL Server. The tables for the application also sit on the Server. I'm having a problem with ODBC on only one of about 10 machines. All the other machines...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
1
by: Mr. B | last post by:
VB.net 2003 c/w Framework 1.1 and MS Access db We have a commercial program that does our Acounting and Time Sheets (Timberline). At least once a day our Accounting department runs a Script...
1
by: BD | last post by:
Hi, all: I have been tasked with determining how many licenses of a certain SQL Server 2000-based application are actually in use: in other words, record or log connections made to the database...
9
by: phil | last post by:
We have a small website using Visual basic and ASP.NET. We hold a database in Access format which is opened with the following 3 lines Dim m_dataBase As String =...
38
by: kavsak | last post by:
Hi. Not sure that this is the right place to ask but here goes. I have an application based on access97 and VB6 which I need to upgrade. It has to handle up to 20 concurrent users on a Win2k...
1
by: Chevylover54 | last post by:
We have been using ODBC connections that are in the registry of the computer. However these connections aren't in by default so when a new user uses the Access program or when a current user goes to...
5
by: John | last post by:
I have an ASP.NET 2.0 application developed in VB.net, that accesses an Microsoft Access database. When the database is on the same IIS server all works just fine. BUT when it tried to access the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.