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 / Forms / April 2008

Tip: Looking for answers? Try searching our database.

reading from query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Smoki - 08 Apr 2008 14:56 GMT
Hy friends,
one probably easy question for other.
I made a form, and I want to connect fields from my form with query. When I
fill one field in form, I want that my query fill other fields on my form.
Control source of my field "Number" is set ok, and in my combo box I see all
of the numbers which I enter, but when I choose any number from my drop down
list, it doesn't react, like I didn't do anything, like I didn't choose any
number.
Solution is... What to do?
I hope that I explain this ok?
strive4peace - 08 Apr 2008 22:34 GMT
FindRecord
~~~

Hi Smoki,

you need to set the form RecordSource to the query

if you wanto to make a combo to find a record that is already there, do
this:

Make one or more unbound combos on your form (like in the header).  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 "SomeID = " & 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
- SomeID is the Name of the primary key field, which is in the
RecordSource of the form -- assuming your primary key is a Long Integer
data type (autonumbers are long integers)

Remember that the Rowsource for a combo can come from anywhere -- it can
pull from multiple tables or only use one ... just make sure that the
first column is the primary key ID of the table you want to search (and
that field is part of the RecordSource for the form you are searching).

If you are searching the recordset on another form, change the
FindRecord name to be specific (like FindRecord_Order) and, substitute

Me --> forms!formname

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

Warm Regards,
Crystal

 *
   (: have an awesome day :)
 *

> Hy friends,
> one probably easy question for other.
[quoted text clipped - 6 lines]
> Solution is... What to do?
> I hope that I explain this ok?
Smoki - 09 Apr 2008 10:56 GMT
Hi Crystal, I done this:

Private Sub Form_AfterUpdate()

  = FindRecord()

End Sub

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 "ID = " & 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

But it doesn't appear in other fields anything, when I choose in my Number
field!
Name of my primary key field is ID, and I changed that.
But, it still doesn't work!
Some help again...

Thanks,
Smoki

> FindRecord
> ~~~
[quoted text clipped - 78 lines]
> > Solution is... What to do?
> > I hope that I explain this ok?
strive4peace - 09 Apr 2008 16:30 GMT
Hi Smoki,

the reason to make FindRecord a function is to put the call of it
DIRECTLY in the property (sorry I did not make that clear).  You do not
need an [Event Procedure], type this IN the AfterUpdate property on the
property sheet:

=FindRecord()

for better understanding of the basics of Access, print and read this:

Access Basics (on Allen Browne's site)
http://www.allenbrowne.com/casu-22.html
8-part free tutorial that covers essentials in Access

Allen has a wealth of information on his site; after you get to the
bottom of this link, click on 'Index of Tips'

Warm Regards,
Crystal

 *
   (: have an awesome day :)
 *

> Hi Crystal, I done this:
>
[quoted text clipped - 121 lines]
>>> Solution is... What to do?
>>> I hope that I explain this ok?
Smoki - 10 Apr 2008 09:37 GMT
Again me.
I have more questions, again :(

I done like you said, but it still doesn't work. Do I have instead of
Me.ActiveControl in brackets () to put Combo13, because it is the name of my
combo box, where I choose number, and than all of the other fields (I have
only text fields) have been filled automatically from that specific row in
query, which contain that number which I enter in my Combo13?

Thanks,
Smoki

> Hi Smoki,
>
[quoted text clipped - 146 lines]
> >>> Solution is... What to do?
> >>> I hope that I explain this ok?
strive4peace - 10 Apr 2008 17:10 GMT
Hi Smoki,

read this:

Access Basics (Access MVP site)
http://www.accessmvp.com/Strive4Peace/Index.htm
8-part free tutorial that covers essentials in Access

Warm Regards,
Crystal

 *
   (: have an awesome day :)
 *

> Again me.
> I have more questions, again :(
[quoted text clipped - 158 lines]
>>>>> Solution is... What to do?
>>>>> I hope that I explain this ok?
 
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.