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

DoCmd.RunSQL

Jim
I am using Access 97 on a PC running Windows NT 4.0 SP6a.

I have some code (shown below) intended to add a set of records to one
table (tblGradeProps) when a new record is created in another
(tblGrades)

The oddity is that when the procedure Detail_Click is called from the
procedure cmbMktSect_Exit, the RunSQL statement doesn't add the
required records but it does so when invoked by the Detail_Click
event!

I've been messing with this for days without success. At one time I
was using an Append Query with DoCmd.OpenQuery and while it wouldn't
add records when called by the code it did so when opened manually
from the database window. Now the query is just a convenient place to
store the SQL string.

Any help or suggestions will be gratefully received.

************START OF CODE FRAGMENT**********************
Private Sub cmbMktSect_Exit(Cancel As Integer)
'this field can be exited on all records so we need to find out if
we're dealing with a new record
If Me![cmbMktSect].BackColor = vbYellow Then 'this is a new
record
'we're dealing with a new record and must add property record to
the table "tblGradeProps"

'reset the grade and sector fields to the default condition.
Me![cmbMktSect].Locked = True
Me![Grade].Locked = True
Me![Grade].BackColor = vbWhite
Me![cmbMktSect].BackColor = vbWhite

Debug.Print "Called from cmbMktSect_Exit"

Call detail_click
'reset the record source so that the market sector text can be
read
cmbMktSect.RowSource = "tblMktSector"

'reset the drop-down menu to show only 1 row
Me![cmbMktSect].ListRows = 1

End If
End Sub

Sub detail_click()
Dim strSQL As String

strSQL = CurrentDb.QueryDefs("qryAppSecProps").SQL

Debug.Print Me![cmbMktSect]
Debug.Print Me![GradeID]
Debug.Print strSQL

DoCmd.RunSQL strSQL
'DoCmd.OpenQuery "qryAppSecProps", acViewNormal, acAdd
'Debug.Print CurrentDb.QueryDefs("qryAppSecProps").SQL
Me.Refresh

End Sub
***************END OF CODE FRAGMENT
Nov 12 '05 #1
0 8208

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

Similar topics

4
by: Rotsj | last post by:
Hi, i try to execute an update query from within a form, but i get the message: run time error '3144'. Syntax error on the update statement when i try something like this: DoCmd.RunSQL...
0
by: Andy | last post by:
Hello, I am running an sql statement that INSERTS INTO a table. If I run the query using docmd.runSQL, it works fine - new records are added to the table and duplicate records are disregared (...
3
by: Pathfinder | last post by:
Hi All I am trying to run the below but I receive the following error "runsql action requires an argument consisting of an SQL statment" Dim MySQL$ MySQL$ = "Select * from mytablename"...
7
by: Richard Hollenbeck | last post by:
Help! I don't know why this isn't working: Private Sub Combo9_Change() Dim UsersCourseSelection As String UsersCourseSelection = Me("Combo9").Value Combo13.Visible = True 'the following...
8
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
6
by: David | last post by:
I am trying to insert an employee number into the EmpNbr field in my main table from a form where I add a new employee to my employee table. I was hoping this command would work, but it isn't. ...
2
by: ben | last post by:
I have the following code in a VBA module: DoCmd.RunSql "Update tData Set sd = Log(Strike/Price) where symbol = '" & symbol & "'" This statement worked fine, and was using the built in math...
3
by: jl2886 | last post by:
Hello. I have two questions: Private Sub Form_Load() Dim assID As Long assID = DMax("CLng(Right(,3))", "Master_Log") Me.LSI_Case_Number = Month(Date) & Format(Year(Date), "yy") & "-" &...
1
by: natural | last post by:
Good Afternoon I have an option grou[ and on the after update i would like to provide the user with a msgbox, and then action placed my docmd.setwarnings false everywhere, but i still get my...
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...
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
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,...
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.