
I have this database to control the spares in several places(Obras), in the movimentos 2 form we introduce if is a out (saida) or entry (Entrada), we put the place (Obra), for that movement we have several ferramentas (tools), we put the tool (ferramenta), the quantity. After i want to update the stock of each tool, for that I created a form Movimentos e Ferramentas Atualizar Stock, that is to create 2 movements (1 to update the warehouse (armazem) and other to update the place with the stock of that tool).
Still didnt put the code to create the records.
the code is this:
Private Sub Command25_Click()
'Dim tipomov As String
'Dim UltimoIMOVFerra As Long
'Dim Obra As Long
'Dim Armazem As Long
'Dim Data As Date
'Dim IDMOV As Long
'Dim IDObra As Long
'Dim IDFerramenta As Long
'Dim Quantidade As Long
Obra = Me![IDObra]
Armazem = 2
Data = Me![Data]
IDMOV = Me![IDMovimento]
tipomov = Me![TipoMovimento]
Me![Movimentos e Ferramentas].SetFocus
DoCmd.GoToRecord , , acLast
UltimoIMOVFerra = Forms![Movimentos 2]![Movimentos e Ferramentas].Form![IDMOVFerra]
DoCmd.GoToRecord , , acFirst
Do Until UltimoIMOVFerra <> Forms![Movimentos 2]![Movimentos e Ferramentas].Form![IDMOVFerra]
If tipomov = "Saída" Then
IDFerramenta = Forms![Movimentos 2]![Movimentos e Ferramentas].Form![IDFerramenta]
Quantidade = Forms![Movimentos 2]![Movimentos e Ferramentas].Form![Quantidade]
DoCmd.OpenForm "Movimentos e Ferramentas Atualizar Stock", acNormal
End If
If tipomov = "Entrada" Then
DoCmd.OpenForm "Movimentos e Ferramentas Atualizar Stock", acNormal
End If
If tipomov = "Inventário" Then
DoCmd.OpenForm "Movimentos e Ferramentas Atualizar Stock", acNormal
End If
Loop
End Sub
But when pass the until instruction the variables lost their value.
I defined that variables in a global module.
Can someone help me?
Thank you.