473,387 Members | 1,453 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.

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 tblMedicalTraits WHERE SystemID = " & CLng(Me.OpenArgs)
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
tblMedicalTraits. It's referring to the SystemID column in
tblMedicalTraits.

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.

tblMedicalTraits 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 2515
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.OpenArgs) 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.comwrote:
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.OpenArgs) or Me.OpenArgs <"" then
* * * ...
* *End If
End Sub

Rich

*** Sent via Developersdexhttp://www.developersdex.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 tblMedicalTraits 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 tblMedicalTraits"
If Not IsNull(Me.OpenArgs) 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.OpenRecordset("tblMedicalTraits")
cmd.ActiveConnection = "Provider=SQLOLEDB; Data
Source=yourSvr;Database=yourDB;Trusted_Connection= 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.comwrote:
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 tblMedicalTraits 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 tblMedicalTraits"
If Not IsNull(Me.OpenArgs) 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.OpenRecordset("tblMedicalTraits")
* cmd.ActiveConnection *= "Provider=SQLOLEDB; Data
Source=yourSvr;Database=yourDB;Trusted_Connection= 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 Developersdexhttp://www.developersdex.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 tblMedicaltraits?

On Jun 2, 1:09*pm, EManning <manning_n...@hotmail.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 tblMedicalTraits WHERE SystemID = " & CLng(Me.OpenArgs)
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
tblMedicalTraits. *It's referring to the SystemID column in
tblMedicalTraits.

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.

tblMedicalTraits 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.comwrote:
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 Developersdexhttp://www.developersdex.com***
Thanks guys. I think I may have found the problem. I was updating
the foreign key for tblMedicalTraits in the Form_Current event. I
moved it to the Form_BeforeUpdate 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
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...
6
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...
3
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. ...
2
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...
7
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...
4
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...
7
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 -...
2
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,...
10
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.