Results 1 to 6 of 6
  1. #1
    Join Date
    May 2014
    Posts
    4

    Unanswered: VBA code for simple record search

    Hi..

    I am new to using access. can someone please help me write a code to search for a record by record id that contains numbers and letters or/and by department that contains letters.

    Please help asap since Ive to submit this project.

    Thanks.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    easiest solution

    use the inbuilt tools in the Access form designer

    if you need to this via VBA, then I'd suggest you use a filter
    you will need a command button to apply the filter, and I'd recommend one to remove the filter. if your VBA skills are up to it you could use one button, pressign the button toggles the filter on or off

    to set a filter you need to define it
    eg
    Code:
    me.filter = "mynumericcolumn = " & anumerictgextcontrol.value
    or
    Code:
    me.filter = "mytextcolumn = '" & atextcontrol.text & "'"
    ..then activate it
    Code:
    me.filteron = true
    or to deactivate it
    Code:
    me.filteron = false
    there's nowt to stop you applying a filter on m,ore than one column at the same time
    eg
    Code:
    me.filter = "mynumericcolumn = " & anumerictgextcontrol.value AND mytextcolumn = '" & atextcontrol.text & "'"
    you can do partial matches on text columns
    eg
    Code:
    me.filter = "mytextcolumn like '*" & atextcontrol.text & "*'"
    ..and so on.
    numeric literals (values) must be as is
    text literals must be delimted by either ' or "
    eg [code]me.filter = "userid = 'Sabika'"
    date literals must be in ISO or US format delimited by #
    eg [code]me.filter = "logondate = #2014/05/12#"

    so what have you tried so far?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2014
    Posts
    4

    Using access for the first time.

    Hi healdem,

    Thanks for replying.

    I don't have anything. This is the first time I am working on access.

    I will attach the form that I want to search from.

    Please take a look and see if you can help me out there.

    Thanks,
    Sabika.
    Last edited by sabika; 05-18-14 at 17:58.

  4. #4
    Join Date
    May 2014
    Posts
    4
    .................
    Last edited by sabika; 05-18-14 at 17:57.

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    nope, its your coursework that you have to hand in. so im not going ot do.
    try your best to follow the suggestions above, and if and when you get stuck by all means ask questions, but Im not going to "do".....
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    May 2014
    Posts
    4
    Can you provide me a useful link where I can learn the basics?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •