Error when saving new record (1 Viewer)

aahmn

Registered User.
Local time
Yesterday, 23:59
Joined
Jul 29, 2011
Messages
15
I tried to teach myself Access to take on a few projects that ended up being more complicated than expected. I have a patient database I've been working on, and I've gotten past most of the major problems but now I'm stuck on something that's probably simple. I have been staring at this thing so long I'm ready to be done.

I used a macro from a microsoft sample database that either opens a current record in a new form or starts a new record. I've had no issues changing the form names in the macro and getting it to work in the past. I put it in a few more places, and none of the new ones work without an error message. You can open and edit current records, but when you add a new one and close the form, it says, "The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data." Then an error shows up for the macro that opens a new record. Here's the error information:

OnClick: Embedded Macro Condition
True: IsNull([HospID])
Action Name
SetTempVar
Arguments
[FONT=&quot]CurrentID, Nz(DMax(“[HospID]”,[Form]![RecordSource]),0)[/FONT]

I don't see what I did differently with the new ones that I didn't do with the old? The funny thing is, if you close the form and reopen it, the info you try to add does actually get added.
I'm attaching a copy of the database - I've stripped it way down and am only including what's needed to see what I might be messing up. The 'Open/New' link works in the Pregnancy and Care Plan tabs, but not in Appointments or Hospitalization.

Also, I have to say that I know I probably made things way more complicated than they need to be. I didn't see easy ways to do the cascading combos, etc without more forms... and I can't do much with VBA.
 

Attachments

  • TestDatabase.accdb
    1.9 MB · Views: 113

BBQ Kittens

Registered User.
Local time
Yesterday, 21:59
Joined
Apr 22, 2011
Messages
49
umm k, well your sample database does not include the macro you are having trouble with nor does it include the form in which it references ie RecordSource. It is unclear to me which form this macro was placed in, how it is selected, why you are using it, etc
 

aahmn

Registered User.
Local time
Yesterday, 23:59
Joined
Jul 29, 2011
Messages
15
If I download the copy I posted and open it, everything is there? The macros are in the form ParentInfo under the Appointments and Hospitalization tabs (the working one is in the Care Plan tab). If you view the properties of the 'Open' text box, it's under the "On Click' events as an embedded macro. It's used to either open a current record to edit or start a new one (in a separate form).
I have no idea what the RecordSource part was - I thought it was some generic labeling of some sort because the embedded macros work everywhere else...
 

Users who are viewing this thread

Top Bottom