473,770 Members | 3,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linked SQL tables/popup form problem

I have an A2003 database linked to SQL Server 2005. My problem is
with a popup form with a filtered table as a recordsource. I set the
filter with an SQL statement like this:

SELECT * FROM tblMedicalTrait s WHERE SystemID = " & CLng(Me.OpenArg s)
Me.RecordSource = strSQL

This opens the popup form just fine when there are records that meet
the filter. If there are no records, then the popup displays 2
"blank" records. What I expect to see is one blank record. It's
almost like there is already a record out there but it's blank. (This
could be better explained if I could attach a screen-shot of what I'm
seeing.) If I try to close the popup without entering anything, I get
an error message that a null cannot be inserted into a field in
tblMedicalTrait s. It's referring to the SystemID column in
tblMedicalTrait s.

This does not happen if there are records already in the table that
meet the filter criteria. I can enter/edit/delete records just fine.
It happens only when there are no records.

tblMedicalTrait s has an IDENTITY field in it so that it will link
correctly to the mdb. It also has a TIMESTAMP field in it to avoid
any write conflicts that these types of databases sometimes get. I
tried removing both thinking that one of them was causing this
problem. But if I remove the IDENTITY field, I just get a popup form
with no fields on it at all, just the outline of the form

Has anybody had this problem? If so, what did you do to correct it?
Thanks for any help or advice.
Jun 27 '08 #1
7 2539
Are you running the sql statement in the popup form's load event? If
you are (or if you aren't you should run the statement in the form load
event) you should add an "If/Then" statement

Private Sub frmPopup_Load()
If Not IsNull(Me.OpenA rgs) or Me.OpenArgs <"" then
...
End If
End Sub

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #2
On Jun 2, 1:40*pm, Rich P <rpng...@aol.co mwrote:
Are you running the sql statement in the popup form's load event? *If
you are (or if you aren't you should run the statement in the form load
event) you should add an "If/Then" statement

Private Sub frmPopup_Load()
* *If Not IsNull(Me.OpenA rgs) or Me.OpenArgs <"" then
* * * ...
* *End If
End Sub

Rich

*** Sent via Developersdexht tp://www.developersd ex.com***
Thanks for your reply. Yes, the statement is in the Form_Load event.
I check for null OpenArgs in the load event before the SQL statement
is executed. So unless I'm missing something, what you suggested is
good programming practice but it doesn't help my situation.
Jun 27 '08 #3
I overlooked the part where you are linking to a sql server 2005 table.
That changes things a little bit. For that I would use ADO. Keep using
OpenArgs, and

If OpenArgs is not null and <"" then pull the records using ADO.

So - instead of having tblMedicalTrait s be a linked table - make it a
local table. You populate it as needed with ADO. When you call the
Popup form - first clear the table

Private Sub Form_Load()
DoCmd.RunSql "Delete * From tblMedicalTrait s"
If Not IsNull(Me.OpenA rgs) And Me.OpenArgs <"" Then
Dim cmd As New ADODB.Command, RS As New ADODB.Recordset
Dim RS1 As DAO.Recordset, i As Integer
Set RS1 = CurrentDB.OpenR ecordset("tblMe dicalTraits")
cmd.ActiveConne ction = "Provider=SQLOL EDB; Data
Source=yourSvr; Database=yourDB ;Trusted_Connec tion=Yes"
cmd.CommandText = "Select * From tblX Where someArg = '" & me.OpenArgs
& "'"
Set RS = cmd.Execute
While Not RS.EOF
RS1.AddNew
For i = 0 to RS.Fields.Count - 1
RS1(i) = RS(i)
Next
RS1.Update
RS.MoveNext
Loop
End If
...
End Sub

Just Make sure you make a reference to Microsoft ActiveX DataObjects 2.x
Library in Tools/References first.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #4
On Jun 2, 2:42*pm, Rich P <rpng...@aol.co mwrote:
I overlooked the part where you are linking to a sql server 2005 table.
That changes things a little bit. *For that I would use ADO. *Keep using
OpenArgs, and

If OpenArgs is not null and <"" then pull the records using ADO. *

So - instead of having tblMedicalTrait s be a linked table - make it a
local table. *You populate it as needed with ADO. *When you call the
Popup form - first clear the table

Private Sub Form_Load()
DoCmd.RunSql "Delete * From tblMedicalTrait s"
If Not IsNull(Me.OpenA rgs) And Me.OpenArgs <"" Then
* Dim cmd As New ADODB.Command, RS As New ADODB.Recordset
* Dim RS1 As DAO.Recordset, i As Integer
* Set RS1 = CurrentDB.OpenR ecordset("tblMe dicalTraits")
* cmd.ActiveConne ction *= "Provider=SQLOL EDB; Data
Source=yourSvr; Database=yourDB ;Trusted_Connec tion=Yes"
* cmd.CommandText = "Select * From tblX Where someArg = '" & me.OpenArgs
& "'"
* Set RS = cmd.Execute
* While Not RS.EOF
* * RS1.AddNew
* * For i = 0 to RS.Fields.Count - 1
* * * RS1(i) = RS(i)
* * Next
* * RS1.Update
* * RS.MoveNext
* Loop
End If
..
End Sub

Just Make sure you make a reference to Microsoft ActiveX DataObjects 2.x
Library in Tools/References first.

Rich

*** Sent via Developersdexht tp://www.developersd ex.com***
This table is used by multiple users. So everytime the popup form is
opened, I would have to recreate the table locally, fill it with data,
then append it to the table linked to SQL Server?

Jun 27 '08 #5
I can't duplicate this problem. I show one record only.

Do you have Navigation Buttons Showing? How many records does it show?

Perhaps there is a blank record in tblMedicaltrait s?

On Jun 2, 1:09*pm, EManning <manning_n...@h otmail.comwrote :
I have an A2003 database linked to SQL Server 2005. *My problem is
with a popup form with a filtered table as a recordsource. *I set the
filter with an SQL statement like this:

SELECT * FROM tblMedicalTrait s WHERE SystemID = " & CLng(Me.OpenArg s)
Me.RecordSource = strSQL

This opens the popup form just fine when there are records that meet
the filter. *If there are no records, then the popup displays 2
"blank" records. *What I expect to see is one blank record. *It's
almost like there is already a record out there but it's blank. *(This
could be better explained if I could attach a screen-shot of what I'm
seeing.) *If I try to close the popup without entering anything, I get
an error message that a null cannot be inserted into a field in
tblMedicalTrait s. *It's referring to the SystemID column in
tblMedicalTrait s.

This does not happen if there are records already in the table that
meet the filter criteria. *I can enter/edit/delete records just fine.
It happens only when there are no records.

tblMedicalTrait s has an IDENTITY field in it so that it will link
correctly to the mdb. *It also has a TIMESTAMP field in it to avoid
any write conflicts that these types of databases sometimes get. *I
tried removing both thinking that one of them was causing this
problem. *But if I remove the IDENTITY field, I just get a popup form
with no fields on it at all, just the outline of the form

Has anybody had this problem? *If so, what did you do to correct it?
Thanks for any help or advice.
Jun 27 '08 #6
If all the users are using the same Front End -- you need to change
that. Each user should have an individual copy of the front end. Of
course, now you introduce deployment/distribution issues. This has been
an on-going/age old problem in the Access community -- trying to use
Access in a Multi-User/Corporate environment. Thus came the emergence
of the .Net environment which specifically addresses and solves these
issues.

When you are talking Microsoft Server DB's and Multi-User environment --
you should be thinking "I need something that was specifically designed
for this kind of environment - I realize that Access is a file based
RDBMS and thus not the most ideal solution for a Server DB/Multi-user
based project".

In the meantime, I would go with the Individual copies of the Front end
for each user. This is the alternative to the main solution of stepping
up to the .Net environment for this kind of project.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #7
On Jun 2, 6:25*pm, Rich P <rpng...@aol.co mwrote:
If all the users are using the same Front End -- you need to change
that. *Each user should have an individual copy of the front end. *Of
course, now you introduce deployment/distribution issues. *This has been
an on-going/age old problem in the Access community -- trying to use
Access in a Multi-User/Corporate environment. *Thus came the emergence
of the .Net environment which specifically addresses and solves these
issues. *

When you are talking Microsoft Server DB's and Multi-User environment --
you should be thinking "I need something that was specifically designed
for this kind of environment - I realize that Access is a file based
RDBMS and thus not the most ideal solution for a Server DB/Multi-user
based project".

In the meantime, I would go with the Individual copies of the Front end
for each user. *This is the alternative to the main solution of stepping
up to the .Net environment for this kind of project.

Rich

*** Sent via Developersdexht tp://www.developersd ex.com***
Thanks guys. I think I may have found the problem. I was updating
the foreign key for tblMedicalTrait s in the Form_Current event. I
moved it to the Form_BeforeUpda te event and now the problem appears to
be gone.

This is in the development phase right now but yes, every user will
have their own front-end. We've used Access for many years but are
considering using Visual Studio for our front-ends for reasons you
gave and because of the persistent rumor that VBA will be replaced by
VB.Net. I'm currently doing some test development in VB.Net.
Jun 27 '08 #8

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

Similar topics

6
6784
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used the SQL Profile to watch the T-SQL-Command which Access ( who creates the commands?) creates and noticed:
6
94553
by: Max | last post by:
Hi, I have SqlServer 2000 as back end and Access 2000 as front-end. All tables from Sqlserver are linked to Access 2000. I am having write conflict problem with one of my form which is bound to a query which consist of let say tableA , TableB and TableC (all are linked tables from SqlServer. While the form is open I am modifying TableA through code on Form_AfterUpdate Event and getting the following message.
3
19495
by: Michael Plant | last post by:
Hello one and all. I have a stored table in my database and the form I'm using is based on a query that draws data from my stored table and a linked table. The linked table is a *.txt file. However, whenever I try to edit data I get the error message "Updating data in a linked table is not supported by this ISAM." I can understand not being able to edit the linked data, but the field I'm trying to update is drawn from the stored...
2
2530
by: Vern Shellman | last post by:
We've got a form in Access 97 SR-2 that works fine with local tables. The pertinent VB code populating a combo box looks like this: Private Function ShowMOFInfo() Dim db As Database Dim rec As Recordset Dim ccode As Integer Dim strAD As String
7
11834
by: Joe | last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource (using Oracle ODBC drivers). After linking the tables in Access, I inspect the data contained in the linked tables. For tables that involve a number field as the primary key, the data is returned successfully. For tables that involve a character field (e.g. CHAR(3) or VARCHAR(10)) as the primary key, I have the correct number of rows returned, but the data displayed...
4
3210
by: glenhong | last post by:
Hi I need some help here. I am running Access 2003. I have an Access DB linked (Front-end) to another Access DB (Back-end). I have a Form which has a third party grid on it. The grid is populated by creating an adodb recordset and assigning the recordset to the grid.
7
3427
by: smd | last post by:
Hello and thanks for taking the time to read this. I've looked all over the web and newsgroups and can't find a solution to my problem. I've posted this question to the Access 2000 group as well - sorry for cross posting. Back ground: User at remote site has Access 2000 running on XP (don't know SP of either). Linked tables are DB2 v8 running on AIX. All of the linked tables are in the same database and schema.
2
6009
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database, and the linked tables are successfully created. I use the data from these linked tables in several forms. All works great until I close the Access frontend and open it again. When I try to use the forms, I get an error message: "Could not...
10
7706
by: Jim Devenish | last post by:
I have a split front end/back end system. However I create a number of local tables to carry out certain operations. There is a tendency for the front end to bloat so I have set 'compact on close' I think that I have read in some threads (althoug I cannot find them now) that others place such tables in a local, linked database. I could do this but I am interested to know what would be the advantages. And disadvantages, if any. Any...
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10057
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9869
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8883
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.