problem referencing controls on tab controls

julian_morgan

New member
Local time
Today, 10:53
Joined
Apr 15, 2010
Messages
9
Hi All,
Really stuck on this one! gonna Loose my job if not careful :-( :banghead:

I have a form (FrmMachines) with a five page tab contol.
I have a subform on each page which are all identical except that they each show a datasheet of records for a different machine number 1-5. (FrmMC1Sub, 2 ,3 ,4, 5).

On each record in the subform there are two buttons:-

MarkCut: updates a tickbox in the parent table and refreshes the form tabs.

Move: changes the value of [machine] in the parent table from a value chosen from a combo box called moveitem.

The code works on the first tab but when i change to another tab, it falls over. It says runtime error 2424 - the expression you entered has a field, control or property name that access cant find.

I'm aware that tabs may need to be referenced in different ways so have tried various different referencing methods, but nothing seemed to work.
I have also tried removing the tabs in favour of one form with buttons for each machine that change the source of the subform but i get exactly the same problem.

Also i cant seem to find the right way to refresh all tab pages/current tab page.

Heres my code for the two buttons:-

Many thanks in advance!
Jools:banghead:

------------------------------------------

Private Sub MarkCut_Click()

Dim str As String
Dim Ord As String
Dim Quant As String
Ord = Me!Order.Value
Quant = Me!Qty.Value

str = "UPDATE SundryItems SET CuttingCompleted = True WHERE Order_Number = " + Ord + " And Qty = " + Quant
DoCmd.RunSQL str
MsgBox "Order Line Marked As Cut", , "Action Successful !"


Forms!FrmMachines!FrmMC1Sub.Form.Requery

End Sub

------------------------------------------------------------------------


Private Sub Move_Click()
Dim str As String
Dim Dest As String
Dim Ord As String
Dim Quant As String

Dest = Me.MoveItem.Column(0)
Ord = Me!Order.Value
Quant = Me!Qty.Value
DoCmd.SetWarnings False

str = "UPDATE SundryItems SET Machine = " + Dest + " WHERE Order_Number = " + Ord + " And Qty = " + Quant
DoCmd.RunSQL str
MsgBox "Order Line Moved To Machine" & " " & Dest, , "Action Successful !"

Forms!FrmMachines!FrmMC1Sub.Form.Requery

DoCmd.SetWarnings True

End Sub
 
Tabs aren't referenced at all when considering the controls embedded in them. Whether you plant a control inside a tab or outside, the way to refer to it is the same.

Also, if you consider it a fun excercise left to the reader to guess which line generated the error, then I assure you it is not :D When asking for help, always say which line.
 
I have a subform on each page which are all identical except that they each show a datasheet of records for a different machine number 1-5. (FrmMC1Sub, 2 ,3 ,4, 5).
Is it exact the same subform, did you check it, (how and where do you get it to show the different machines, by filter or ...?)?
 
Also, although this isn't your current problem, the ampersand (&) is the standard VBA concatenation operator. Although the plus (+) can be used, it works differently when one of the operands is null and cannot be used to concatenate two numeric values since its use as an arithmetic operator has presidence.
 

Users who are viewing this thread

Back
Top Bottom