|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
stLinkCriteria ???
Hey all
I'm a beginner in using MS Access, hope can learn a lot from this forum. I have problems in implementing the stLinkCriteria to open a new form by double clicking a data in a List box. I have 2 forms : "Show Group" and "Edit Group" for now, the List Box in the "Show Group" form and the "Edit Group" form itself has the same source which is "Group" The "Group" table has primary key of "GroupCode" and another parameter "GroupName" I shows the complete data from the "GroupCode" throught the List Box in the "Show Group" form. In the List Box properties, i make a code as following ------------------------------------------------------------------------ Private Sub GroupList_DblClick(Cancel As Integer) Dim stDocName As String Dim stLinkCriteria As String stDocName = "Edit Group" stLinkCriteria = "[GroupCode]=" & Me![GroupList] DoCmd.OpenForm stDocName, , , stLinkCriteria End Sub ------------------------------------------------------------------------- In the "Edit Group" form it self, i make 2 text box to display the selected data. Everytime i try to execute, it gives the following error Let say i pick a row with "GroupCode" = BOT and "GroupName" = Boring Tool -------------------------------------------------------------------------- Run-time error '3075' : Syntax error(missing operator) in query expression '[GroupCode] = Boring Tool'. --------------------------------------------------------------------------- But if i pick a row with "GroupCode" = CUT, "GroupName" = Cutter or "GroupCode" = DRI , "GroupName" = Drill or "GroupCode" = INS , "GroupName" = Insert it will prompt me with a pop up box to insert a parameter value. If i fill in the "GroupCode", it will show up the "EditGroup" form with a true result. It seems that it reads the similiarity between the "GroupCode" and the "GroupName" I'm really clueless about this problem and hope can learn from you guys. And please don't be annoyed by me, because i think i'm going to be a regular visitor and post a lot of problems for couple of weeks ahead. Thank you very much in advance ![]() |
|
#2
|
||||
|
||||
|
if the Groupcode is a textfield datatype then
place single quotes before and after value field as below stLinkCriteria = "[GroupCode] = '" & Me![GroupList] & "'" |
|
#3
|
|||
|
|||
|
Thx it works, but only after i change the following
stLinkCriteria = "[GroupName] = '" & Me![GroupList] & "'" Instead of using the primary key, i use the other parameter which is the "GroupName". If i use "GroupCode" there will be no more error messages but it also shown nothing in the "Edit Group" form. If i change to "GroupName" it works exactly like i wanted. What is the reason for this ?? Is it something to do with primary key or somewhere along the line i do something wrong ?? Thx |
|
#4
|
|||
|
|||
|
One more enquiry....
Now using the same structure i try to delete the record selected in the list box -------------------------------------------------- Function Delete() If MsgBox("Do You really want to delete the selected Group ?", vbOKCancel + vbDefaultButton2 + vbQuestion, "Confirmation") = vbOK Then Dim db As Database Dim rs As Recordset Set db = CurrentDb Set rs = db.OpenRecordset("Group", dbOpenDynaset) rs.Find ("[GroupName]= " & Forms![Show Group]![GroupList].Value) rs.Delete rs.Close Forms![Show Group]![GroupList].Requery End If End Function ------------------------------------------------------- it returns "Run Time error 13, type mismatch" Can someone enlight me for this particular issue ? |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > stLinkCriteria ??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|