473,471 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Previously working code not working now!

Hi all, I am reusing code that was used in a previous copy of the DB.
I am trying to extract data from other tables, queries and a form and
put it in a table. The code was used previously and worked without any
problems. I am trying to figure out what is causing the problem. I
presume there is probably a missing reference but I can't tell. Parts
of the code works but it appears the following portion is not working.

'Action3: If the Proposal is already added to tblPanel, then Update the
record. Else, add new Record in tblPanel and update the fields

strSQLChair = "SELECT * FROM qrychair" & _
" WHERE [proposalid] = '" & strProposalID & "'"
strSQLOrganizer = "SELECT * from tblOrganizer" & _
" WHERE [proposalid] = '" & strProposalID & "'"
strSQLDisc1 = "SELECT * FROM qryDiscussant1" & _
" WHERE [proposalid] = '" & strProposalID & "'"
strSQLDisc2 = "SELECT * FROM qryDiscussant2" & _
" WHERE [proposalid] = '" & strProposalID & "'"
Set rsChair = db.OpenRecordset(strSQLChair, dbOpenDynaset)
Set rsPanelDetails = db.OpenRecordset("tblpanel", dbOpenDynaset)
Set rsOrganizer = db.OpenRecordset(strSQLOrganizer, dbOpenDynaset)
Set rsDisc1 = db.OpenRecordset(strSQLDisc1, dbOpenDynaset)
Set rsDisc2 = db.OpenRecordset(strSQLDisc2, dbOpenDynaset)
strFound = "SELECT * FROM tblPanel" & _
" WHERE [proposalid] = '" & strProposalID & "'"
Set rsFoundPanel = db.OpenRecordset(strFound, dbOpenDynaset)
If Not (rsFoundPanel.RecordCount = 0) Then
With rsFoundPanel
.Edit
!PanelID = strpanelid
!AREARANK = strRank
!PROPOSALID = strProposalID
!TYPE = rsChair!PROPOSALTYPE
!PANELNAME = rsChair!PROPOSALTITLE
!AREA = rsChair!AREA
If Not rsChair.RecordCount = 0 Then
!CHAIRFIRST = rsChair!FIRST
!CHAIRMI = rsChair!MI
!CHAIRLAST = rsChair!LAST
!CHAIRAFFILIATION = rsChair!AFFILIATION
!CHAIRADDRESS1 = rsChair!ADDRESS1
!CHAIRADDRESS2 = rsChair!ADDRESS2
!CHAIRADDRESS3 = rsChair!ADDRESS3
!CHAIRCITY = rsChair!CITY
!CHAIRSTATE = rsChair!STATE
!CHAIRZIP = rsChair!ZIP
!CHAIRCOUNTRY = rsChair!COUNTRY
!CHAIRTELE = rsChair!PHONE
!CHAIRFAX = rsChair!FAX
!CHAIREMAIL = rsChair!EMAIL
End If
If Not rsDisc1.RecordCount = 0 Then
!DIS1FIRST = rsDisc1!FIRST
!DIS1MI = rsDisc1!MI
!DIS1LAST = rsDisc1!LAST
!DIS1AFFILIATION = rsDisc1!AFFILIATION
!DIS1ADDRESS1 = rsDisc1!ADDRESS1
!DIS1ADDRESS2 = rsDisc1!ADDRESS2
!DIS1ADDRESS3 = rsDisc1!ADDRESS3
!DIS1CITY = rsDisc1!CITY
!DIS1STATE = rsDisc1!STATE
!DIS1ZIP = rsDisc1!ZIP
!DIS1COUNTRY = rsDisc1!COUNTRY
!DIS1TELE = rsDisc1!PHONE
!DIS1FAX = rsDisc1!FAX
!DIS1EMAIL = rsDisc1!EMAIL
End If
If Not rsDisc2.RecordCount = 0 Then
!DIS2FIRST = rsDisc2!FIRST
!DIS2MI = rsDisc2!MI
!DIS2LAST = rsDisc2!LAST
!DIS2AFFILIATION = rsDisc2!AFFILIATION
!DIS2ADDRESS1 = rsDisc2!ADDRESS1
!DIS2ADDRESS2 = rsDisc2!ADDRESS2
!DIS2ADDRESS3 = rsDisc2!ADDRESS3
!DIS2CITY = rsDisc2!CITY
!DIS2STATE = rsDisc2!STATE
!DIS2ZIP = rsDisc2!ZIP
!DIS2COUNTRY = rsDisc2!COUNTRY
!DIS2TELE = rsDisc2!PHONE
!DIS2FAX = rsDisc2!FAX
!DIS2EMAIL = rsDisc2!EMAIL
End If
!Organizer = rsOrganizer!OFIRST & " " & rsOrganizer!OLAST
!ORGANIZERTELE = rsOrganizer!OPHONE
!ORGANIZEREMAIL = rsOrganizer!OEMAIL
.Update
End With

Else
With rsPanelDetails
.AddNew
!PanelID = strpanelid
!AREARANK = strRank
!PROPOSALID = strProposalID
!TYPE = rsChair!PROPOSALTYPE
!PANELNAME = rsChair!PROPOSALTITLE
!AREA = rsChair!AREA
If Not rsChair.RecordCount = 0 Then
!CHAIRFIRST = rsChair!FIRST
!CHAIRMI = rsChair!MI
!CHAIRLAST = rsChair!LAST
!CHAIRAFFILIATION = rsChair!AFFILIATION
!CHAIRADDRESS1 = rsChair!ADDRESS1
!CHAIRADDRESS2 = rsChair!ADDRESS2
!CHAIRADDRESS3 = rsChair!ADDRESS3
!CHAIRCITY = rsChair!CITY
!CHAIRSTATE = rsChair!STATE
!CHAIRZIP = rsChair!ZIP
!CHAIRCOUNTRY = rsChair!COUNTRY
!CHAIRTELE = rsChair!PHONE
!CHAIRFAX = rsChair!FAX
!CHAIREMAIL = rsChair!EMAIL
End If
If Not rsDisc1.RecordCount = 0 Then
!DIS1FIRST = rsDisc1!FIRST
!DIS1MI = rsDisc1!MI
!DIS1LAST = rsDisc1!LAST
!DIS1AFFILIATION = rsDisc1!AFFILIATION
!DIS1ADDRESS1 = rsDisc1!ADDRESS1
!DIS1ADDRESS2 = rsDisc1!ADDRESS2
!DIS1ADDRESS3 = rsDisc1!ADDRESS3
!DIS1CITY = rsDisc1!CITY
!DIS1STATE = rsDisc1!STATE
!DIS1ZIP = rsDisc1!ZIP
!DIS1COUNTRY = rsDisc1!COUNTRY
!DIS1TELE = rsDisc1!PHONE
!DIS1FAX = rsDisc1!FAX
!DIS1EMAIL = rsDisc1!EMAIL
End If
If Not rsDisc2.RecordCount = 0 Then
!DIS2FIRST = rsDisc2!FIRST
!DIS2MI = rsDisc2!MI
!DIS2LAST = rsDisc2!LAST
!DIS2AFFILIATION = rsDisc2!AFFILIATION
!DIS2ADDRESS1 = rsDisc2!ADDRESS1
!DIS2ADDRESS2 = rsDisc2!ADDRESS2
!DIS2ADDRESS3 = rsDisc2!ADDRESS3
!DIS2CITY = rsDisc2!CITY
!DIS2STATE = rsDisc2!STATE
!DIS2ZIP = rsDisc2!ZIP
!DIS2COUNTRY = rsDisc2!COUNTRY
!DIS2TELE = rsDisc2!PHONE
!DIS2FAX = rsDisc2!FAX
!DIS2EMAIL = rsDisc2!EMAIL
End If
!Organizer = rsOrganizer!OFIRST & " " & rsOrganizer!OLAST
!ORGANIZERTELE = rsOrganizer!OPHONE
!ORGANIZEREMAIL = rsOrganizer!OEMAIL
.Update
End With

End If

MsgBox "Proposal Accepted As Is"
Forms!frmBuildSessions.Refresh

errtrap:
End Sub

Apr 26 '06 #1
5 1703
Guh! That's a monster, and without the rest of the code or a copy of
the database it'd be hard to tell you what's wrong.

Try adding a break point in the code just before this section. If you
click on the left margin of the code you'll get a little red circle;
that's a breakpoint.

Once you hit the breakpoint Access will jump into the code. Hit the F8
key and you'll "step" through the code. Keep hitting F8 and take note
of what's happening and what's being processed. You should be able to
narrow down the issue pretty quickly doing that.

Also, each time you hit F8 let your mousepointer hover above the
variables your code just processed. It should show up on your screen
what the variables were set to. If you see something out of the
ordinary, look at what the variable was set to and try to figure out
what it's doing.

I know that's not the answer you were looking for, but after you do it
a few times you'll be able to figure out alot of this stuff on your own
pretty quickly.

Apr 26 '06 #2
Thank you, I'll try that.

Apr 26 '06 #3
I tried to debug by stepping through the code and I don't think the
code is working in the following lines:

Set rsChair = db.OpenRecordset(strSQLChair, dbOpenDynaset)
Set rsPanelDetails = db.OpenRecordset("tblpanel", dbOpenDynaset)
Set rsOrganizer = db.OpenRecordset(strSQLOrganizer, dbOpenDynaset)
Set rsDisc1 = db.OpenRecordset(strSQLDisc1, dbOpenDynaset)
Set rsDisc2 = db.OpenRecordset(strSQLDisc2, dbOpenDynaset)
' tells you what function the strings are equal to but give no value
strFound = "SELECT * FROM tblPanel" & _
" WHERE [proposalid] = '" & strProposalID & "'"
Set rsFoundPanel = db.OpenRecordset(strFound, dbOpenDynaset)
' here the string is equal to ""
If Not (rsFoundPanel.RecordCount = 0) Then
' get the error msg: object variable or with block variable not set. I
am not sure how to correct this error; please help!

Apr 26 '06 #4
In the original code there will be a partial line similar to
Set rsFoundPanel =

This is not happening in your ode before the line where the error is
occurring. You need to correct this.

--

Terry Kreft
"dBNovice" <lu*****@hotmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
I tried to debug by stepping through the code and I don't think the
code is working in the following lines:

Set rsChair = db.OpenRecordset(strSQLChair, dbOpenDynaset)
Set rsPanelDetails = db.OpenRecordset("tblpanel", dbOpenDynaset)
Set rsOrganizer = db.OpenRecordset(strSQLOrganizer, dbOpenDynaset)
Set rsDisc1 = db.OpenRecordset(strSQLDisc1, dbOpenDynaset)
Set rsDisc2 = db.OpenRecordset(strSQLDisc2, dbOpenDynaset)
' tells you what function the strings are equal to but give no value
strFound = "SELECT * FROM tblPanel" & _
" WHERE [proposalid] = '" & strProposalID & "'"
Set rsFoundPanel = db.OpenRecordset(strFound, dbOpenDynaset)
' here the string is equal to ""
If Not (rsFoundPanel.RecordCount = 0) Then
' get the error msg: object variable or with block variable not set. I
am not sure how to correct this error; please help!

Apr 27 '06 #5
This line of code does exists. Note the 16th line above:"Set
rsFoundPanel = db.OpenRecordset(strFound, dbOpenDynaset) "
I think the problem exists when I set the recordsets to equal the
corresponding SQL string. For example, after the following line of
code, the code still get the msg strSQL...= Empty.

i.e. strSQLChair = "SELECT * FROM qrychair" & _
" WHERE [proposalid] = '" & strProposalID & "'"
Set rsChair = db.OpenRecordset(strSQLChair, dbOpenDynaset) '
here strSQLChair = Empty

Apr 27 '06 #6

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

Similar topics

3
by: krose | last post by:
I have created an Installer using the "Setup Wizard" in Visual Studio. I've added a custom action to this as a seperate DLL written in C#. The custom action has to install files from another...
0
by: krose | last post by:
I have created an Installer using the "Setup Wizard" in Visual Studio. I've added a custom action to this as a seperate DLL written in C#. The custom action has to install files from another...
3
by: krose | last post by:
I have created an Installer using the "Setup Wizard" in Visual Studio. I've added a custom action to this as a seperate DLL written in C#. The custom action has to install files from another...
482
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. ...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.