| |||||||||
|
| New! Download a running example of the Docmd.RunSQL Method |
Such functions as creating temporary tables and building queries based on the user's responses to question creates an environment of almost infinite flexibility.
Below is an example of appending data to a temporary table based on the records within a master form on the screen. This gives us programmatic control of the details form data. Not that the records for the detail form comes from separate tables. This query could also have been done using a Union query:
Private Sub Form_Current()
Dim SQLText As String
' JW Dean Blue Claw Database Design 7/25/2006
' disable editing if previous order number has been filledin
'
If IsNull(Me.Previous_Order_) = True Then
Me.AllowEdits = True
Else
Me.AllowEdits = False
End If
' clear out temp table
DoCmd.RunSQL "Delete * from t_orders"
'
'create and run the append queries
'
SQLText = "INSERT INTO T_Orders ( Order_Numb, ITEMDESC, XTNDPRCE, QUANTITY )
SELECT SOPNUMBE, ITEMDESC, XTNDPRCE, QUANTITY " & _
"FROM SOP10200 where SOPNumbe='" & Me.Previous_Order_ & "' or sopnumbe='" &
Me.ReplOrder_ & "' or sopnumbe='" & Me.CR_ & "'"
'
DoCmd.RunSQL SQLText
'
'
SQLText = "INSERT INTO T_Orders ( Order_Numb, ITEMDESC, XTNDPRCE, QUANTITY )
SELECT SOPNUMBE, ITEMDESC, XTNDPRCE, QUANTITY " & _
"FROM SOP30300 where SOPNumbe='" & Me.Previous_Order_ & "' or sopnumbe='" &
Me.ReplOrder_ & "' or sopnumbe='" & Me.CR_ & "'"
'
DoCmd.RunSQL SQLText
' refresh the form
Form_F_Previous_Details.Requery
End Sub
More runsql examples:
Docmd
DoCmd Run SQL, Run an SQL action query by using the SQL command. You may
also run a DDL query. DoCmd Send Object, Include the specified
datasheet, form,...
Inventory Calculations Example - Single User Databases
This Access database download shows how you can use the Docmd.Runsql
statement in the after update (afterupdate) event to increment and
decrement inventory ...
Multi-Select Parameter Forms
select name,address1,address2,city,state,zip from q_daily_prospect_Pitney" DoCmd.RunSQL (sqltext) Set rst =
db.OpenRecordset("select count(name) as icount ...
|
A Blue Claw Database Design Template: Farmer's Feed Inventory Tracking Database |
|
A Blue Claw Database Design Article: MS Access Versus Other Systems |
|
Contact Information Copyright 2000-2012 Blue Claw Database Design, LLC
|