Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

Search option

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sebastico - 10 May 2007 00:05 GMT
Hello
In a form based in the below table:

ID  (PK Autonumeric)                    
CodPer (FK txt)
CodProd1(FK txt) (combo box in the form)
CodUT (FK txt)
F1 (Numeric)
F2 (Numeric)

How do I use (do I need code?) a cmd button to find records in CodProd field?

Many Thanks
strive4peace - 10 May 2007 02:25 GMT
Make one or more unbound combos on your form.  Let the first column be
invisible and be the primary key ID of the recordsource of your form and
then, on its AfterUpdate event...

=FindRecord()

this code goes behind the form:

'~~~~~~~~~~~~~~~~~~~~
Private Function FindRecord()

   'if nothing is picked in the active control, exit
   If IsNull(Me.ActiveControl) Then Exit Function

   'save current record if changes were made
   If me.dirty then me.dirty = false

   'declare a variable to hold the primary key value to look up
   Dim mRecordID As Long

   'set value to look up by what is selected
   mRecordID = Me.ActiveControl

   'clear the choice to find
   Me.ActiveControl = Null

   'find the first value that matches
   Me.RecordsetClone.FindFirst "IDfield = " & mRecordID

   'if a matching record was found, then move to it
   If Not Me.RecordsetClone.NoMatch Then
      Me.Bookmark = Me.RecordsetClone.Bookmark
   End If

End Function

'~~~~~~~~~~~~~~~~~~~~
where
-IDfield is the Name of the primary key field, which is in the
RecordSource of the form -- I am assuming your primary key is a Long
Integer data type (autonumbers are long integers)
-ProcedureName is the name of the procedure that the code is in so if
there is an error, you can see you can see where it is

If you are searching the recordset on another form, substitute
Me --> forms!formname

If on a subform:
Me --> Me.subform_controlname.form

~~~
btw, you should give you ID field a specific name, like UnitID,
ProductID, PriceID, etc...

Warm Regards,
Crystal
 *
     (:  have an awesome day  :)
  *
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
  *

> Hello
> In a form based in the below table:
[quoted text clipped - 9 lines]
>
> Many Thanks
sebastico - 10 May 2007 17:51 GMT
Crystal many thanks

I'm new to programming, i do not well undesrtand your message. Please see my
lines

I do not how to make one or more unbound combos on my form. Where I find the
first column.
Once I have the combo where do I have to clik to copy =FindRecord() ?

Where in the form do I have to click to copy the code you suggest?

I need the combo only in CodProd field

Thanks againg

> Make one or more unbound combos on your form.  Let the first column be
> invisible and be the primary key ID of the recordsource of your form and
[quoted text clipped - 73 lines]
> >
> > Many Thanks
strive4peace - 10 May 2007 20:04 GMT
Hi sebastico (what is your name?)

for better understanding, download and read this:

Access Basics
http://allenbrowne.com/tips.html
Tips for Casual Users
Access Basics: free tutorial - Word document by Crystal (Access MVP)

This 30-page training tutorial will orient you toward the core concepts
of Microsoft Access -- good foundation for learning programming

~~~

once you read the above document, post back with your questions <smile>

Warm Regards,
Crystal
 *
     (:  have an awesome day  :)
  *
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
  *

> Crystal many thanks
>
[quoted text clipped - 88 lines]
>>>
>>> Many Thanks
sebastico - 16 May 2007 21:12 GMT
Hi.  Crystal. The code works great. Many thanks again.
My name is Sebastian. Where do you live?
Warm regards

> Hi sebastico (what is your name?)
>
[quoted text clipped - 114 lines]
> >>>
> >>> Many Thanks
strive4peace - 17 May 2007 03:23 GMT
you're welcome, Sebastian ;)  happy to help

Warm Regards,
Crystal
 *
     (:  have an awesome day  :)
  *
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
  *

> Hi.  Crystal. The code works great. Many thanks again.
> My name is Sebastian. Where do you live?
[quoted text clipped - 118 lines]
>>>>>
>>>>> Many Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.