SQL -> VBA Translation
Jul 19, 2006I'm having trouble converting SQL to VBA. Can someone help?
Original SQL
SELECT tsubPermissionList.UserID, tblMainData.TrackingID, tblMainData.WorkOrder, tblMainData.ActionDescription, tblMainData.Facility, tblMainData.Status, tblMainData.ResponsibleParty, tblMainData.[WHS ID], tblMainData.[PM ID], tblMainData.ProgramID, tblMainData.Location, tblMainData.Branch, tblMainData.Unit, tblMainData.DueDate, tblMainData.ActualStartDate, tblMainData.ActualCompletionDate, tblMainData.Completed, tblMainData.LastModified, tblMainData.CreatedBy, tblMainData.CreatedWhen, tblMainData.EditedBy, tblMainData.EditedWhen, tblMainData.Comments, tblMainData.EmailSent, tblMainData.EmailSender, tblMainData.Selected, *
FROM tsubPermissionList INNER JOIN tblMainData ON tsubPermissionList.FullName = tblMainData.ResponsibleParty
WHERE (((tblMainData.WorkOrder) Like "*" & [Forms]![frmMainEntry]![txtCurrentWorkSearch2] & "*")) OR (((tblMainData.ActionDescription) Like "*" & [Forms]![frmMainEntry]![txtCurrentWorkSearch2] & "*")) OR (((tblMainData.Facility) Like "*" & [Forms]![frmMainEntry]![txtCurrentWorkSearch2] & "*")) OR (((tblMainData.Status) Like "*" & [Forms]![frmMainEntry]![txtCurrentWorkSearch2] & "*"));
My attempt to translate it to VBA.
strSelect = "SELECT DISTINCTROW tblMainData.TrackingID, tblMainData.WorkOrder, tblMainData.ActionDescription, tblMainData.Facility, tblMainData.ResponsibleParty, tblMainData.Status, tsubPermissionList.UserID, tsubPermissionList.FullName, *"
strFrom = " FROM tsubPermissionList"
strJoin = " INNER JOIN tblMainData ON tsubPermissionList.FullName = tblMainData.ResponsibleParty"
strWhere = " WHERE tblMainData.WorkOrder Like " & "" * "" & "'"" & [Forms]![frmMainEntry]![txtCurrentWorkSearch2] " & "'" & "*" & _
" OR tblMainData.ActionDescription Like " & "" * "" & "'"" & [Forms]![frmMainEntry]![txtCurrentWorkSearch2] " & "'" & "*" & _
" OR tblMainData.Facility Like " & "" * "" & "'"" & [Forms]![frmMainEntry]![txtCurrentWorkSearch2] " & "'" & "*" & _
" OR tblMainData.Status Like " & "" * "" & "'"" & [Forms]![frmMainEntry]![txtCurrentWorkSearch2] " & "'" & "*" Thanks,
PC