MS Access - please help!

Discussion in 'Software' started by pari22, Aug 24, 2007.

  1. pari22

    pari22 Corporal

    Hello,
    MS ACCESS 2002 Question,

    I have a MAIN FORM with multiple subform (Auto Lookup Query)in it.
    I've been trying to figure out a way to copy a VALUE from subform's filed into MAIN FORM's filed - after you update value of the subform.
    For example,
    When I search a person's profile (SSN, Address...) by NAME in subform, I want all the searched fileds' values to copy to the MAIN FORM. (NAME & SSN & ADDRESS) so it can store the values in main table.
    Now, as I understand, this is supposed to be pretty easy by using codes. I've got some info from the net and tried it... keep failing. Been trying to use VB codes, expression builder. trying to use "AfterUpdate" command...
    CAN ANYONE HELP ME WITH THIS?
    I know you will need more info from me, but I don't even know what to list here... sorry for being stupid...

    Thank you for your future help!
     
  2. Mada_Milty

    Mada_Milty MajorGeek

    Could you post the existing code, and maybe as a visual aid, screenshots of the forms?

    I'm thinking this should be as easy as using:

    Code:
    [I]controlname1[/I].value = [I]controlname2[/I].value
    But may require something as complex as a Dlookup (complex being RELATIVE)
     
  3. pari22

    pari22 Corporal

    Thank you for your reply, kind sir!
    First, here is the screenshot of basic form. I can't get you the whole thing, because of the company policy and stuff.... sorry.... But I think you'll get the idea. Subform works great. All the function is working except the red box area. I'd like to get the values from the subform after I search for the client.

    For the code part, nothing worked..., or should I say I couldn't make things work, so there are no special codes in right now.
    Can you give some advice? I tried your "controlname1.value = controlname2.value" in the VB code by changing it to "[client-query].NAME = [MAINFORM].CLIENTNAME" , but didn't work... I'm pretty sure I'm missing something.

    Please help.
     

    Attached Files:

  4. pari22

    pari22 Corporal

    little update...
    I was thinking..., but should I go with a command button in order to copy the values? It looks like it makes more sense... but if you have any other ideas, I'm listening...
    Oh, and I don't know the code for the button either...

    Thank you
     
  5. Mada_Milty

    Mada_Milty MajorGeek

    IMO, it would be easier from an end-user's perspective to have the client information update on a change of the client-query drop down. It's just slightly more automatic. The 'afterupdate' event of the drop down would likely be perfect for this, and it looks like it may already be in use, anyway.

    We've ALMOST got the code right there. We need something more like this:

    Code:
    [I]subformname[/I].[I]controlname[/I].value = [I]mainformname[/I].[I]controlname[/I].value
    We have to include the 'value' property of the objects we are working with. We'd need only to enter a line like this for every control that's getting populated into the 'AfterUpdate' procedure for the subform drop down menu.
     
  6. pari22

    pari22 Corporal

    Mada,
    Thank you very much for your help so far. It kinda gives me an idea where you're going with this...
    I've changed my codes to following. Main form's name is now: testing. Subform's name is now: client-query subform1. two fields I'm testing with is: "name" & "phone".
    =code=
    Private Sub Name_AfterUpdate()
    [client-query subform1].Name.Value = [testing].Name.Value
    End Sub

    Private Sub phone_AfterUpdate()
    [client-query subform1].phone.Value = [testing].phone.Value
    End Sub
    =end code=
    I've put this code by going to: Subform's fields' property - clicked on "event" tab - clicked on "after update"'s event procedure - clicked on "build code" button next to it (...) - and put the code in VB window...
    Am I doing this right? Because it's not workin... It gives me errors.
    when I change the name in subform,
    error #1: this field is read-only...
    error #2: Run-time error '2465':
    Microsoft Access can't find the field "I" (looks like straight line) referred to in your expression.

    I checked all my fields, and non are set to read only... and I do not have "I" field defined anywhere in my code as you can see...
    Can you help, please???
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds