Hello,
New to adding SQL script in VBA so looking for your wisdom.
In this database people make requests for a piece of data, is the data they request has already been requested I am looking for a popup to tell the enterer that this has already been requested and the status of the request.
The script is as follows:
_____________________________________________________
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsCount As Integer
Dim SQLtext As String
SQLtext = "SELECT T_Requests.Figure_ID, T_Requests.Purpose, T_Requests.State" & _
"FROM T_Data INNER JOIN T_Requests ON T_Data.Figure_ID = T_Requests.Figure_ID" & _
"WHERE (((T_Requests.Figure_ID) = Forms!T_Data!Figure_ID) And ((T_Requests.Purpose) = Forms!T_Requests!Purpose))" & _
"GROUP BY T_Requests.Figure_ID, T_Requests.Purpose, T_Requests.State"
Set db = CurrentDb
Set rs = db.OpenRecordset(queryNameOrSQL)
rs.MoveLast
rsCount = rs.RecordCount
If rsCount = 1 Then
MsgBox "Record already exists.", vbInformation, "System Error"
___________________________________________________________
Within the message box I would also like to include the purpose of the returned row.
The main issue I currently have is that the SQL text is not recognised as an object.
Sorry its so long but thankyou v much for help in advance,
Oliver
New to adding SQL script in VBA so looking for your wisdom.
In this database people make requests for a piece of data, is the data they request has already been requested I am looking for a popup to tell the enterer that this has already been requested and the status of the request.
The script is as follows:
_____________________________________________________
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsCount As Integer
Dim SQLtext As String
SQLtext = "SELECT T_Requests.Figure_ID, T_Requests.Purpose, T_Requests.State" & _
"FROM T_Data INNER JOIN T_Requests ON T_Data.Figure_ID = T_Requests.Figure_ID" & _
"WHERE (((T_Requests.Figure_ID) = Forms!T_Data!Figure_ID) And ((T_Requests.Purpose) = Forms!T_Requests!Purpose))" & _
"GROUP BY T_Requests.Figure_ID, T_Requests.Purpose, T_Requests.State"
Set db = CurrentDb
Set rs = db.OpenRecordset(queryNameOrSQL)
rs.MoveLast
rsCount = rs.RecordCount
If rsCount = 1 Then
MsgBox "Record already exists.", vbInformation, "System Error"
___________________________________________________________
Within the message box I would also like to include the purpose of the returned row.
The main issue I currently have is that the SQL text is not recognised as an object.
Sorry its so long but thankyou v much for help in advance,
Oliver