OVH Cloud OVH Cloud

recordSEt

3 réponses
Avatar
david
JE ne comprend pas pourquoi le type recordSet ne marche=20
pas dans mon programme.

Private Sub Form_Current()
Dim SQLRequest As String
Dim rst As Object
Dim result As String
=20
If Me![Id prix] > 0 Then
Else
GoTo Err_Prix_From
End If
=20
SQLRequest =3D "SELECT [ID Soci=E9t=E9] " & _
"FROM [Contract] " & _
"WHERE [Contract].[Id prix] =3D " & Me!
[Id prix] & ";"
=20
Set rst =3D CurrentDb.OpenRecordset(SQLRequest)
=20
If rst.RecordCount =3D 0 Then
GoTo Err_Prix_From
End If
=20
result =3D rst.Fields("ID Soci=E9t=E9")
rst.Close
=20
SQLRequest =3D "SELECT [Soci=E9t=E9] " & _
"FROM [Soci=E9t=E9] " & _
"WHERE [Soci=E9t=E9].[ID Soci=E9t=E9] =3D " &=20
result & ";"
=20
=20
=20
Set rst =3D CurrentDb.OpenRecordset(SQLRequest)
=20
If rst.RecordCount =3D 0 Then
GoTo Err_Prix_From
End If

result =3D rst.Fields("Soci=E9t=E9")
rst.Close
Me![Soci=E9t=E9 name] =3D result
=20
Err_Prix_From:
End Sub

3 réponses

Avatar
Jean-Pierre
Moi non plus ...

-----Message d'origine-----

JE ne comprend pas pourquoi le type recordSet ne marche
pas dans mon programme.

Private Sub Form_Current()
Dim SQLRequest As String
Dim rst As Object
Dim result As String

If Me![Id prix] > 0 Then
Else
GoTo Err_Prix_From
End If

SQLRequest = "SELECT [ID Société] " & _
"FROM [Contract] " & _
"WHERE [Contract].[Id prix] = " & Me!
[Id prix] & ";"

Set rst = CurrentDb.OpenRecordset(SQLRequest)

If rst.RecordCount = 0 Then
GoTo Err_Prix_From
End If

result = rst.Fields("ID Société")
rst.Close

SQLRequest = "SELECT [Société] " & _
"FROM [Société] " & _
"WHERE [Société].[ID Société] = " &
result & ";"



Set rst = CurrentDb.OpenRecordset(SQLRequest)

If rst.RecordCount = 0 Then
GoTo Err_Prix_From
End If

result = rst.Fields("Société")
rst.Close
Me![Société name] = result

Err_Prix_From:
End Sub

.



Avatar
Jeff
Bonjour

Est que [Id Prix] et [Id Société] sont numérique ou alphanumérique ?
Dans le second cas tu dois mettre entre guillemets, Chr$(34).

J'aurais personnellement utilisé DLookUp.

result = Dlookup("ID Société","Contract","[Id prix] = " & Me![Id prix])
If IsNull(result) Then Goto Err_Prix_From
result = Dlookup("Société","Société","[ID Société]=" & result)
If IsNull(result) Then Goto Err_Prix_From
Me![Société name] = Result

If Me![Id prix] > 0 Then
Else
GoTo Err_Prix_From
End If



A mon sens il faudrait plutôt :

If Me![Id prix] <= 0 Then Goto Err_Prix_From

Cordialement

Jeff

"david" a écrit dans le message de
news:129a01c351c9$de69fc30$

JE ne comprend pas pourquoi le type recordSet ne marche
pas dans mon programme.

Private Sub Form_Current()
Dim SQLRequest As String
Dim rst As Object
Dim result As String

If Me![Id prix] > 0 Then
Else
GoTo Err_Prix_From
End If

SQLRequest = "SELECT [ID Société] " & _
"FROM [Contract] " & _
"WHERE [Contract].[Id prix] = " & Me!
[Id prix] & ";"

Set rst = CurrentDb.OpenRecordset(SQLRequest)

If rst.RecordCount = 0 Then
GoTo Err_Prix_From
End If

result = rst.Fields("ID Société")
rst.Close

SQLRequest = "SELECT [Société] " & _
"FROM [Société] " & _
"WHERE [Société].[ID Société] = " &
result & ";"



Set rst = CurrentDb.OpenRecordset(SQLRequest)

If rst.RecordCount = 0 Then
GoTo Err_Prix_From
End If

result = rst.Fields("Société")
rst.Close
Me![Société name] = result

Err_Prix_From:
End Sub


Avatar
david
Merci les gars,
il s'agissait uniquement d'un pb de librairie.
david.


-----Message d'origine-----
Bonjour

Est que [Id Prix] et [Id Société] sont numérique ou
alphanumérique ?

Dans le second cas tu dois mettre entre guillemets,
Chr$(34).


J'aurais personnellement utilisé DLookUp.

result = Dlookup("ID Société","Contract","[Id prix] = " &
Me![Id prix])

If IsNull(result) Then Goto Err_Prix_From
result = Dlookup("Société","Société","[ID Société]=" &
result)

If IsNull(result) Then Goto Err_Prix_From
Me![Société name] = Result

If Me![Id prix] > 0 Then
Else
GoTo Err_Prix_From
End If



A mon sens il faudrait plutôt :

If Me![Id prix] <= 0 Then Goto Err_Prix_From

Cordialement

Jeff

"david" a écrit dans le
message de

news:129a01c351c9$de69fc30$

JE ne comprend pas pourquoi le type recordSet ne marche
pas dans mon programme.

Private Sub Form_Current()
Dim SQLRequest As String
Dim rst As Object
Dim result As String

If Me![Id prix] > 0 Then
Else
GoTo Err_Prix_From
End If

SQLRequest = "SELECT [ID Société] " & _
"FROM [Contract] " & _
"WHERE [Contract].[Id prix] = " & Me!
[Id prix] & ";"

Set rst = CurrentDb.OpenRecordset(SQLRequest)

If rst.RecordCount = 0 Then
GoTo Err_Prix_From
End If

result = rst.Fields("ID Société")
rst.Close

SQLRequest = "SELECT [Société] " & _
"FROM [Société] " & _
"WHERE [Société].[ID Société] = " &
result & ";"



Set rst = CurrentDb.OpenRecordset(SQLRequest)

If rst.RecordCount = 0 Then
GoTo Err_Prix_From
End If

result = rst.Fields("Société")
rst.Close
Me![Société name] = result

Err_Prix_From:
End Sub


.