Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form is blank until PartNumber is selected

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
Below is the code I have on an AfterUpdate Event from a ComboBox. It populates unbound fields on the form from a query. This works find. My issue is-until I select a Partnumber from the ComboBox none of the unbound fields on the form show. The Form is Blank. How can I have all of the fields on the form show without selecting a partnumber from the ComboBox? The Form is a Single Form.

Code:
Private Sub PartNumberSelect_AfterUpdate()

Forms("MainEntryFrm").Requery

Me.PartNumber10 = DLookup("PartNumber", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.PrimarySupplier10 = DLookup("PrimarySupplier", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.OPERATION10 = DLookup("Operation", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.FrozenUsage10 = DLookup("FROZEN_USA", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.KBQty10 = DLookup("KANBAN_QTY", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.FrozenKbQty10 = DLookup("KB_QUANTIT", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.CONTAINER10 = DLookup("CONTAINER_", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.PiecesPer10 = DLookup("PIECES_PER", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.NumberContainers10 = DLookup("NUMBER_OF", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
Me.PullStep10 = DLookup("SURROGATE_", "MainEntryQrySelect", "Surrogate_ = 1 or Surrogate_ is null")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Me.PartNumber20 = DLookup("PartNumber", "MainEntryQrySelect", "Surrogate_ = 2")
Me.PrimarySupplier20 = DLookup("PrimarySupplier", "MainEntryQrySelect", "Surrogate_ = 2")
Me.OPERATION20 = DLookup("Operation", "MainEntryQrySelect", "Surrogate_ = 2")
Me.FrozenUsage20 = DLookup("FROZEN_USA", "MainEntryQrySelect", "Surrogate_ = 2")
Me.KBQty20 = DLookup("KANBAN_QTY", "MainEntryQrySelect", "Surrogate_ = 2")
Me.FrozenKbQty20 = DLookup("KB_QUANTIT", "MainEntryQrySelect", "Surrogate_ = 2")
Me.Container20 = DLookup("CONTAINER_", "MainEntryQrySelect", "Surrogate_ = 2")
Me.PiecesPer20 = DLookup("PIECES_PER", "MainEntryQrySelect", "Surrogate_ = 2")
Me.NumberContainers20 = DLookup("NUMBER_OF", "MainEntryQrySelect", "Surrogate_ = 2")
Me.PullStep20 = DLookup("SURROGATE_", "MainEntryQrySelect", "Surrogate_ = 2")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Me.PartNumber30 = DLookup("PartNumber", "MainEntryQrySelect", "Surrogate_ = 3")
Me.PrimarySupplier30 = DLookup("PrimarySupplier", "MainEntryQrySelect", "Surrogate_ = 3")
Me.OPERATION30 = DLookup("Operation", "MainEntryQrySelect", "Surrogate_ = 3")
Me.FrozenUsage30 = DLookup("FROZEN_USA", "MainEntryQrySelect", "Surrogate_ = 3")
Me.KBQty30 = DLookup("KANBAN_QTY", "MainEntryQrySelect", "Surrogate_ = 3")
Me.FrozenKbQty30 = DLookup("KB_QUANTIT", "MainEntryQrySelect", "Surrogate_ = 3")
Me.Container30 = DLookup("CONTAINER_", "MainEntryQrySelect", "Surrogate_ = 3")
Me.PiecesPer30 = DLookup("PIECES_PER", "MainEntryQrySelect", "Surrogate_ = 3")
Me.NumberContainers30 = DLookup("NUMBER_OF", "MainEntryQrySelect", "Surrogate_ = 3")
Me.PullStep30 = DLookup("SURROGATE_", "MainEntryQrySelect", "Surrogate_ = 3")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Me.PartNumber40 = DLookup("PartNumber", "MainEntryQrySelect", "Surrogate_ = 4")
Me.PrimarySupplier40 = DLookup("PrimarySupplier", "MainEntryQrySelect", "Surrogate_ = 4")
Me.OPERATION40 = DLookup("Operation", "MainEntryQrySelect", "Surrogate_ = 4")
Me.FrozenUsage40 = DLookup("FROZEN_USA", "MainEntryQrySelect", "Surrogate_ = 4")
Me.KBQty40 = DLookup("KANBAN_QTY", "MainEntryQrySelect", "Surrogate_ = 4")
Me.FrozenKbQty40 = DLookup("KB_QUANTIT", "MainEntryQrySelect", "Surrogate_ = 4")
Me.Container40 = DLookup("CONTAINER_", "MainEntryQrySelect", "Surrogate_ = 4")
Me.PiecesPer40 = DLookup("PIECES_PER", "MainEntryQrySelect", "Surrogate_ = 4")
Me.NumberContainers40 = DLookup("NUMBER_OF", "MainEntryQrySelect", "Surrogate_ = 4")
Me.PullStep40 = DLookup("SURROGATE_", "MainEntryQrySelect", "Surrogate_ = 4")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Me.PartNumber50 = DLookup("PartNumber", "MainEntryQrySelect", "Surrogate_ = 5")
Me.PrimarySupplier50 = DLookup("PrimarySupplier", "MainEntryQrySelect", "Surrogate_ = 5")
Me.OPERATION50 = DLookup("Operation", "MainEntryQrySelect", "Surrogate_ = 5")
Me.FrozenUsage50 = DLookup("FROZEN_USA", "MainEntryQrySelect", "Surrogate_ = 5")
Me.KBQty50 = DLookup("KANBAN_QTY", "MainEntryQrySelect", "Surrogate_ = 5")
Me.FrozenKbQty50 = DLookup("KB_QUANTIT", "MainEntryQrySelect", "Surrogate_ = 5")
Me.Container50 = DLookup("CONTAINER_", "MainEntryQrySelect", "Surrogate_ = 5")
Me.PiecesPer50 = DLookup("PIECES_PER", "MainEntryQrySelect", "Surrogate_ = 5")
Me.NumberContainers50 = DLookup("NUMBER_OF", "MainEntryQrySelect", "Surrogate_ = 5")
Me.PullStep50 = DLookup("SURROGATE_", "MainEntryQrySelect", "Surrogate_ = 5")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

End Sub
 
Maybe on the load_event of the form, set the unbound fields to ""
Me.field1 = ""

Pampers [afro]
Keeping it simple can be complicated
 
Put all that same code in the forms onCurrent event. Then when the form opens, or changes records, they will still be there. you may need to do an error check on the onCurrent, because if you go to a new record and your comboBox doesn't have anything in it, it might give you an error.

Something like:

if not combo = Null or isnull(combo) or combo = "" then
ENTER ALL THAT DLOOKUP CODE HERE
end if
 
Everyone:

Thanks for your input. I have tried both of your suggestions but the fields do not show up until I
select a PartNumber. Anymore suggestions?
 
This is the behavior encountered when the form has no record source (which yours doesn't, apparently, until you use your dropdown box, and the AllowAdditions Property for the form is set to NO. Go into the form's Property box and set Allow Additions to YES and see what happens.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
missinglinq,

The Allow Additions is already set to YES. Any other suggestions???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top