Circular Reference

G

Guest

I just modified a query in Access 2000 and it has caused a circular
reference. Later I will probally need help getting the calculation without
cause the CR, but as of right now every time I try to open the query in
design view, it closes my Access session. Is there any way I can open this
query so that I can delete the CR???

Please help
Thank you!!!
 
B

Brendan Reynolds

The following two procedures will save the SQL of the query to a text file,
and assign the contents of a text file to the SQL property of the query,
respectively. Run the first procedure (passing the name of your query as the
argument) to save the SQL, then open the text file in a text editor such as
Notepad, and make the necessary changes. Save the text file, then run the
second procedure to update the from the text file.

Public Sub QueryToText(strQueryName As String)

Dim intFile As Integer
Dim strFile As String

strFile = CurrentProject.Path & "\SavedSQL.txt"
intFile = FreeFile

'This will overwrite any file with the same name in the target
'folder. Make sure you don't have anything you want to keep with
'this name in that folder.
Open strFile For Output As intFile
Print #intFile, CurrentDb.QueryDefs(strQueryName).SQL
Close intFile

End Sub

Public Sub TextToQuery(strQueryName As String)

Dim intFile As Integer
Dim strFile As String
Dim strSQL As String

strFile = CurrentProject.Path & "\SavedSQL.txt"
intFile = FreeFile
Open strFile For Input As intFile
Do Until EOF(intFile)
strSQL = strSQL & Input(1, intFile)
Loop
Close intFile
CurrentDb.QueryDefs(strQueryName).SQL = strSQL

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top