hi,
why won't this sql string work in VBA, i tried everything and it seems to be something small, but i don't see the fault
What i try to do is a check if a record already exists with the RefNumber and the companyname.
as you can see is RUit a string and Mednam a number.
this code is placed in the afterupdate on the fields Me.Ref_Uitgever and Me.medium_naam. (this code runs after checking if the fields are filled in)
Anyone knows what i should do? the code stops running at set Lrs so there is something wrong in the sql string i think.
i also made an other function that can check dubble records but i cant get the id number from it to go to that record :s
i think the first method is the best, anyone knows how to get this alive?
A big thanks in advance for the smart guys here off course
greetz
vinzz
why won't this sql string work in VBA, i tried everything and it seems to be something small, but i don't see the fault
What i try to do is a check if a record already exists with the RefNumber and the companyname.
as you can see is RUit a string and Mednam a number.
this code is placed in the afterupdate on the fields Me.Ref_Uitgever and Me.medium_naam. (this code runs after checking if the fields are filled in)
Anyone knows what i should do? the code stops running at set Lrs so there is something wrong in the sql string i think.
Code:
Dim db As Database
Dim Lrs As DAO.Recordset
Dim LSQL As String
Dim RUit As String
Dim Mednam As Long
RUit = Me.Ref_Uitgever.Value
Mednam = Me.medium_naam.Column(0)
Set db = CurrentDb()
LSQL = "SELECT Hoofdform.medium_naam, Hoofdform.Ref_Uitgever FROM Hoofdform WHERE ((Hoofdform.medium_naam='" & Mednam & "') AND (Hoofdform.Ref_Uitgever='" & RUit & "'));"
Set Lrs = db.OpenRecordset(LSQL)
...
i also made an other function that can check dubble records but i cant get the id number from it to go to that record :s
Code:
Dim zoekdos As Long
If Me.medium_naam.Column(0) <> "" And Ref_Uitgever <> "" Then
zoekdos = DCount("id", "hoofdform", "Ref_Uitgever= forms!hoofdform.Ref_uitgever AND Medium_naam= forms!hoofdform.medium_naam")
Debug.Print zoekdos
If zoekdos > 0 Then
MsgBox "blabla"
End If
End If
i think the first method is the best, anyone knows how to get this alive?
A big thanks in advance for the smart guys here off course
greetz
vinzz