Using a combobox to check if record exist then populate form

Anonymous
2014-09-10T22:04:07+00:00

So I have posted my question to several forums and have had some good response but no resolution. I am quite new to Access 2010 and VBA. So here is my issue. I have built a Navigation Page with several forms(bound) so my users can enter data and saved to a table. What I have is a room delay form to capture information for a  medical procedure and to document when a delay occurs. My TABLE is tblDelay and my form is FormDelay.

On occasion my users will enter some information and save and close the form. Then will need to edit the record. I have attempted to create a Assession Num Search in the form header based on someone's recommendation using this code:

Private Sub cboAssessionSearch_AfterUpdate()

Const MESSAGETEXT = "This Assession Number already exists."

 If Not IsNull(DLookup("AssessionNumber", "tblDelay", "AssessionNumber=" & Me.AssessionNumber)) Then

 MsgBox MESSAGETEXT, vbExclamation, "Invalid Operation"

 'code to filter form for the existing record

 Me.Filter = "AssessionNumber=" & Me.AssessionNumber

 Me.FilterOn = True

 Else

 'code to move to new record row

 DoCmd.GoToRecord , , acNewRec

 End If

End Sub

I can find the populated Assession Numbers in the combobox but I need to have certain criteria. If the assession number exists the populate the form with the record fields so an edit can be made and an update to the record made in the table. If the Assession Number does not exist leave the form blank so a new record can be entered. Nothing happens when I select a Assession Number and hit enter. No error message indication record exists or not.

I have built several buttons (Add, Edit, Delate, Clear, and Close) in the header. If a assession Numbers need edited and updated then repopulate the form with the appropriate record found using the Assession Num Search combobox, If no record found, the enter new information.

Table Field Names

dept, Rm_Num, MRN, AssessionNumber, CaseNumber (Not inclusive of all fields, If I can get these filed to populate I can get the rest)

Form Names

cboDept, cboRmNum, txtMRN, txtAssessionNumber, txtCaseNumber (Not inclusive of all boxes)

Bound Form to table

Any help finding resolution would be of GREAT HELP!!! 

Thank you in advance,

Kerry

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

51 answers

Sort by: Oldest
  1. Anonymous
    2014-09-18T18:49:52+00:00

    Sorry, must have brain damage from this project. Here is the link forgot in last post.

    https://onedrive.live.com/redir?resid=9A4AF30CB84FCA5B!106&authkey=!AChlsuCaZs5ztZc&ithint=file%2caccdb

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-09-18T20:50:09+00:00

    I think you must have forgotten to convert it down to Access 2007 format; I can't open it I'm afraid.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-09-18T21:53:54+00:00

    My file states Access 2007-2010. Not sure whats going on, my appologies.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-09-18T22:18:06+00:00

    I just read this Backward compatibility between Access 2010 and Access 2007 at http://msdn.microsoft.com/library/office/dn602608(v=office.14).aspx.

    The only thing I can think of is I have a calculated name field for full name. I have removed the calculated field but do not see how to save as .mdb file or anything for 2007. When I try to save database I do not have a Save as type for 2007? I just do not know what I need to do. Very frustrating. I am sorry.

    Any suggestions?

    KA

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2014-09-18T22:31:11+00:00

    I found where to convert  to .mdb under Save and Publish. It has me change the property Has Module to NO. When I save it it deltes the entire form. All that gets saved is the tables. Unbelievable that this is happening. Banging by head. Very frustrating.

    Any clues are greatly appreciated.

    Was this answer helpful?

    0 comments No comments