Refering to a field in a subform and using gotorecord acnext (1 Viewer)

jbleal21

Registered User.
Local time
Today, 09:36
Joined
May 18, 2018
Messages
12
I have a main form "Movimentos" and a subform "Movimentos e Ferramenta", I want to set focus in the subform, see the values of each record (use acnext) and in the end add a new record.
I tried several expressions but gives always error.
can someone help?
Thank you.
 

Minty

AWF VIP
Local time
Today, 16:36
Joined
Jul 26, 2013
Messages
10,354
What have you tried?

When you say "see each record" how do you envisage that happening? Using a command button? On which form is the command button?
 

jbleal21

Registered User.
Local time
Today, 09:36
Joined
May 18, 2018
Messages
12
Hi,

i put the buttom in the main form
and the code is:
DoCmd.GoToRecord , "Movimentos e ferramentas", acNext
 

Minty

AWF VIP
Local time
Today, 16:36
Joined
Jul 26, 2013
Messages
10,354
You aren't referencing the form correctly. The simplest way is to use the subforms recordset;

Code:
Me.[Movimentos e Ferramenta].Form.Recordset.Movenext

This assumes your subform control is called the same as you actual subform name.
 

jbleal21

Registered User.
Local time
Today, 09:36
Joined
May 18, 2018
Messages
12
I put
Me.[Movimentos e Ferramenta].Form.Recordset.MoveNext

it pass that part without error but gives a new error in this expression:
Forms![Movimentos]![Movimentos e Ferramentas].Form![Stock] = Forms![Movimentos]![Movimentos e Ferramentas].Form![Stock] - Forms![Movimentos]![Movimentos e Ferramentas].Form![Quantidade]
 

Minty

AWF VIP
Local time
Today, 16:36
Joined
Jul 26, 2013
Messages
10,354
Where is that code and what is it supposed to be doing?
What is the error?

You really should remove the spaces and shorten your form names to something easier to read and type - seriously you will get fed up adding [ ] around those names, and I bet will get syntax errors as well.
 

jbleal21

Registered User.
Local time
Today, 09:36
Joined
May 18, 2018
Messages
12
hi:
What is happening now is that i stored some value in variables but when it pass the until instruction they become empty:

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]![Movimentos e Ferramentas].Form![IDMOVFerra]


DoCmd.GoToRecord , , acFirst

Do Until UltimoIMOVFerra <> Forms![Movimentos]![Movimentos e Ferramentas].Form![IDMOVFerra]



If tipomov = "Saída" Then
 

Minty

AWF VIP
Local time
Today, 16:36
Joined
Jul 26, 2013
Messages
10,354
How do you know they become empty - are they being set in the first place to what you expect? Add the following after you set it, and look in the immediate window to see the value

Debug.print "My Value ", UltimoIMOVFerra
 

Users who are viewing this thread

Top Bottom