Query descriptions created in code
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 232   1
URL.หัวข้อ / URL
Query descriptions created in code

มีคนถามไว้ที่ 
http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=32811 
 
ดังนี้ 
 
I used the below to try & create a temporary query that will be routinely created  
& deleted whenever it is called. The below code is meant to create it & append  
a description to the query in case sometime in the future I forget what it’s  
purpose is. Problem is that I get an invalid use of property message on the  
fourth line. I’d appreciate any advice.   
 
Set db = CurrentDb  
Set qd = db.CreateQueryDef("qryEnterPayDetails", strSQL)  
db.QueryDefs("qryEnterPayDetails").Properties ("Test desc")  
DoCmd.OpenQuery "qryEnterPayDetails" 
 
__________________ 
thanks, 
Arage 
 
เขาต้องการที่จะใส่ข้อความในส่วนของ Description ของ Query ที่เขาสร้างขึ้นด้วยโค้ด ทำอย่างไร  
 
ผมตอบเขาให้ใช้ฟังก์ชันนี้ครับ 
 
Function CreateQueryDescrpt(strQuery As String, strDescrpt As String)  
Dim dbs As Database  
Dim qdf As QueryDef  
Dim prop As Property  
 
On Error GoTo Err_CreateQueryDescrpt  
 
Set dbs = CurrentDb  
 
Set qdf = dbs.QueryDefs(strQuery)  
 
With qdf  
For Each prop In .Properties  
' On Error Resume Next  
' Check if Description property already set, change it and exit  
If prop.Name = "Description" Then  
    .Properties("Description") = strDescrpt  
    Debug.Print "Already set"  
    Exit Function  
End If  
Next prop  
 
' If is not yet there, assign it  
Set prop = .CreateProperty("Description", dbText, strDescrpt)  
    .Properties.Append prop  
    .Properties.Refresh  
    Debug.Print "Newly set"  
 
End With  
 
Bye_CreateQueryDescrpt:  
Exit Function  
 
Err_CreateQueryDescrpt:  
Beep  
MsgBox Error$, 48  
Resume Bye_CreateQueryDescrpt  
 
End Function 
 
Description ของ Object ต่างใน Access เราสามารถที่จะคลิกเข้าไปใส่ข้อความด้วยมือก็ได้ครับ โดยคลิกที่สิ่งนั้น เช่น ตารางเป้าหมาย แล้วคลิกขวา>แล้ว Properites แล้วพิมพ์ข้อมความใน Description ลงไป *** Edited by Supap Chaiya *** 3/9/2546 21:51:46

1 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R00576
อีกคำถามหนึ่งถามคล้ายๆ กัน ดูที่ http://www.utteraccess.com/forums/showflat.php?Cat=&Board=access_97&Number=108458&Forum=CatSearch-2&Words=TimK&Match=Username&Searchpage=0&Limit=25&Old=allposts&Main=108374&Search=true#Post108458
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0478s