SergioRocha
Registered User.
- Local time
- Today, 02:30
- Joined
- Dec 7, 2008
- Messages
- 15
Hi,
I've been improving a database and i would like to add a new functionality.
I have the following tables:
Carteira, Compras, Vendas...
I have a main form where i can see the information recorded in those tables. Main form gets the data from table Carteira but i also have subforms in the main form to see the information of the others tables. I want to build a new form that allows me to insert new data into the table Compras. The idea is when i press a button, this new form will appear, then i will insert the data press another button that will record the introduced data into table Compras. Bellow i describe the table fields.
Table Carteira has the fields: Referencia,nome,quantidade,total...
Table Compras has the fields: Referencia, Ref_compra,data,quantidade,total
I've created the following Sub. The goal would be to record the introduced data into table Compras:
Private Sub Comprar()
Dim DB As DAO.Database
Dim rstCarteira, rstCompras As DAO.Recordset
Dim strSQL As String
Set DB = CurrentDb
Set rstCarteira = DB.OpenRecordset("Carteira")
Set rstCompras = DB.OpenRecordset("Compras")
rstCompras.MoveLast
strSQL = "[Ref_compra] =' " & Me.Texto6 & "'"
MsgBox strSQL
With rstCompras
.MoveLast
.FindFirst (strSQL)
If .NoMatch Then
MsgBox "No Match was found."
.MoveNext
Else
MsgBox "It worked!"
End If
End With
Set rstCompras = Nothing
Set rstCarteira = Nothing
Set DB = Nothing
End Sub
When i execute the code i have the following error:
Run-time error '3251'
Operation not supported for this type of object
The debuger points to the line ".FindFirst (strSQL)"
What seems to be the problem???
I've been improving a database and i would like to add a new functionality.
I have the following tables:
Carteira, Compras, Vendas...
I have a main form where i can see the information recorded in those tables. Main form gets the data from table Carteira but i also have subforms in the main form to see the information of the others tables. I want to build a new form that allows me to insert new data into the table Compras. The idea is when i press a button, this new form will appear, then i will insert the data press another button that will record the introduced data into table Compras. Bellow i describe the table fields.
Table Carteira has the fields: Referencia,nome,quantidade,total...
Table Compras has the fields: Referencia, Ref_compra,data,quantidade,total
I've created the following Sub. The goal would be to record the introduced data into table Compras:
Private Sub Comprar()
Dim DB As DAO.Database
Dim rstCarteira, rstCompras As DAO.Recordset
Dim strSQL As String
Set DB = CurrentDb
Set rstCarteira = DB.OpenRecordset("Carteira")
Set rstCompras = DB.OpenRecordset("Compras")
rstCompras.MoveLast
strSQL = "[Ref_compra] =' " & Me.Texto6 & "'"
MsgBox strSQL
With rstCompras
.MoveLast
.FindFirst (strSQL)
If .NoMatch Then
MsgBox "No Match was found."
.MoveNext
Else
MsgBox "It worked!"
End If
End With
Set rstCompras = Nothing
Set rstCarteira = Nothing
Set DB = Nothing
End Sub
When i execute the code i have the following error:
Run-time error '3251'
Operation not supported for this type of object
The debuger points to the line ".FindFirst (strSQL)"
What seems to be the problem???
