Run-time error 3151 (1 Viewer)

Hello1

Registered User.
Local time
Tomorrow, 01:59
Joined
May 17, 2015
Messages
271
Code:
Set Radnik = MyDb.OpenRecordset("SELECT LDRadnik.JMBG,Radnik.ImePrezime, Raspored.Koeficijent, Radnik.BrojGod, LDRadnik.IznosNe1, LDRadnik.IznosNe2, _
    & " LDRadnik.PorManji, LDRadnik.DSPO, LDRadnik.IznosIsp  FROM ((Radnik INNER JOIN LDRadnik ON Radnik.JMBG = LDRadnik.JMBG) _
    & " INNER JOIN Raspored ON LDRadnik.JMBG = Raspored.JMBG) INNER JOIN qryAdekvatnaSis ON Raspored.BrojPra = qryAdekvatnaSis.BrojPra _
    & " WHERE GodinaMj = " & Me.GodinaMJ & "AND VrstaObr = '" & Me.cboVrstaObr & "'")

The code stops on this line, Radnik is "Dim Radnik As Recordset".
I copied the SQL string, pasted it in the immediate window and executed with the ?. Took the SQL pasted it into a new query in query designer, run the query and it works.
I refreshed all linked tables, even re-added the tables involved in the SQL statement but still getting the same error. I also tried with the , dbOpenDynaset, dbSeeChanges at the end o_O
I will remove all the tables and link them again , all the tables involved are on the SQL Server
btw I can access all the tables from Access without any problems
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:59
Joined
Oct 29, 2018
Messages
21,498
Hi. What does the error message say?
 

Hello1

Registered User.
Local time
Tomorrow, 01:59
Joined
May 17, 2015
Messages
271
Ah yeah, sorry 😅
ODBC--connection to "ServerName" failed.
 

Hello1

Registered User.
Local time
Tomorrow, 01:59
Joined
May 17, 2015
Messages
271
Yes, all the tables are on the SQL Server.
I just re-opened Access and now its working, driving me nuts lately heh
Before closing Access I added the tables again, who knows did it mean anything. Anyway, works now
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:59
Joined
Oct 29, 2018
Messages
21,498
Yes, all the tables are on the SQL Server.
I just re-opened Access and now its working, driving me nuts lately heh
Before closing Access I added the tables again, who knows did it mean anything. Anyway, works now
Hi. Glad to hear you got it sorted out. Probably was a network glitch. Good luck with your project.
 

Users who are viewing this thread

Top Bottom