Need Help with an auto pull ...

txgeekgirl

Registered User.
Local time
Yesterday, 20:50
Joined
Jul 31, 2008
Messages
187
I am trying to make a little adjustment (AddVersion) form that feeds from a form called PBCCUpdateForm.

I need Add Version to record the selected Title ID from the PBCCUpdateForm so a new Version for that title can be added.

Add Version has four properties - Textbox to hold TitleID, Input Box for Version and two check boxes for Media Copy or Disaster Recovery Copy.

TitleID In Add Version should equal Title ID from PBCCUpdateForm and log that Title ID into the Applications Table.

Here are some codes I have tried:
'Me.TitleID = DLookup("[TitleID]", "[Title], [TitleID] = " & Str([Forms]![PBCCUpdateForm]![cmbTitle]))

'[TitleID] = DLookup("[TitleID]", "[Title], [TitleID] = " & Str([Forms]![PBCCUpdateForm]![cmbTitle]))

'[TitleID] = DLookup("[TitleID]", "[Title]", "[Title] = " & [Forms]![PBCCUpdateForm]![cmbTitle])

'Me.TitleID = DLookup("[TitleID]", "[Title]", "[TitleID] = " & [Forms]![PBCCUpdateForm]![cmbTitle])

Nothing works. My boss, who is the YODA of DB programming is on vacation and I need help desperately. :eek:
 
Does this "AddVersion" form open on top of "PBCCUpdateForm"? And if so, is the "PBCCUpdateForm" still behind it?

-dK
 
It is minimized on open of Add Version and restored on close.
 
Oh okay ,,,, since the form you want information from is open, one technique you can employ is ...

On the AddVersion form and in the form control for TitleID. Set it's Default Value (in the control properties) to

Code:
= Forms!PBCCUpdateForm!NameofTitleIDControl

When this form opens as a new record, this form control will automatically fill with the information from control on the other form.

-dK
 
OK - two things -

First - Thank you so much for your help.

Second - I have an issue.

If I bind the TitleID to = Forms!PBCCUpdateForm!TitleID in the properties of the box, it does pull the Title ID but does not write it back to the Applications Table (leaves as 0). I need this to happen for the association.

If I leave the box unbound and declare in the code like this in VBA:
[TitleID] = Forms!PBCCUpdateForm!TitleID
[Version] = Me.Version
[OriginalMedia] = Me.OriginalMedia
[DisasterRecoveryCopy] = Me.DisasterRecoveryCopy

It doesn't work. Doesn't pull the number over.

When I am declaring it, do I need to add in there something like:
telling it to write to the Title ID.

I did one for last week and don't know how I did it. Looked like this:
[AppID] = DLookup("[AppID]", "[Applications]", "[Version] = '" & [Forms]![PBCCUpdateForm]![Version] & "' AND [TitleID] = " & Str([Forms]![PBCCUpdateForm]![cmbTitle]))
and it writes the AppID back to the table.... but it is also a comparing argument which to me is like an array and I understood it. This should be simple and I am struggling.

Listen - I have been a web coder for 7 years. HTM, DHTM, XML, CSS, Jscript, PHP, Java (real Java)... I get it. I am trying to retool my brain just a bit and just need some help. Thank you.
 
Make sure the .. = Forms!PBCCUpdateForm!TitleID is in the Default Value box. The control is not unbound, it's Control Source is the TitleID of the AddVersion table.

This allows it to pull the information and save it in the appropriate field.

-dK
 
I should point out that when you automatically load controls with data with a new record, the record really isn't instantiated (for lack of a better term) meaning it's not made in the table until you actually save it, or, you manually enter some data in another control.

-dK
 
Here is my code so far. If I declare the TitleID in the save record it screams at me because I have bound it in the properties. If I do not bind and declare in the Save Record part of the Sub cmdSave_Click() there is no value pulled.


Option Compare Database
Private Sub Form_Load()
DoCmd.GoToRecord A_FORM, CStr(Me.FormName), A_NEWREC
Me.Version.SetFocus
Me.cmdSave.Enabled = True
Me.cmdCancel.Enabled = True
End Sub
Private Sub cmdSave_Click()
On Error GoTo cmdSave_ClickError
'Check all required fields
If IsNull(Me.Version) Then
dummy = ReqMsg("Version", "Version")
GoTo cmdSave_ClickDone
End If

'SaveRecord
'-----> Somthing needs to write the Title ID back here! :confused:
[Version] = Me.Version
[OriginalMedia] = Me.OriginalMedia
[DisasterRecoveryCopy] = Me.DisasterRecoveryCopy


DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, CStr(Me.FormName)

cmdSave_ClickDone:
Exit Sub

cmdSave_ClickError:
Warning Error$, "cmdSave_Click"
DoCmd.Close acForm, CStr(Me.FormName)
Resume cmdSave_ClickDone
End Sub
Private Sub cmdCancel_Click()
On Error GoTo cmdCancel_ClickError
If Me.Dirty Then UndoRecord
'Me.Requery
cmdCancel_ClickDone:
DoCmd.Close acForm, CStr(Me.FormName)
Exit Sub
cmdCancel_ClickError:
Warning Error$, "cmdCancel_Click"
Resume cmdCancel_ClickDone
End Sub
Private Sub Form_Close()
If IsLoaded("Add Version") Then
DoCmd.SelectObject acForm, "PBCCUpdateForm"
DoCmd.Restore
End If
End Sub
 
I see where you are coming from, but then again you are talking to me - maybe I am just not getting it ... =[

I've attached a sample db to demonstrate so you can look at this and I will look at the code you have posted.

-dK
 

Attachments

I got iT!!!!!!!

You totally helped with you simply declaring it from the open form in the property. I had a naming conflict! I just saw it. The table was confused.

I renamed the TitleID on the add version form to txtTitleID and declared that [TitleID] = me.txtTitleID and it wrote!!!!

Thank you so much. You did help. I just couldn't see it! Maybe not enough coffee yet!:p
 
Hehehe ... mmmm .. good ole coffee.

Glad you got it sorted - I hate it when it is something like that. It's like it couldn't possibly be something of that sort because I would never do that! The end result is we never bother checking. Stare and compare is always best for perspective. =]

Good to go.

-dK
 
Well - atleast now I know that I need to really pay attention to naming. It is way different than what you can get away with in other code.

Thank you so much again!!!
 

Users who are viewing this thread

Back
Top Bottom