Swapping data between Forms

wjoc1

Registered User.
Local time
Today, 11:22
Joined
Jul 25, 2002
Messages
117
Hi,

I have two forms, networkRefurbishment and addASpecialCode. After entering information onto the form addASpecialCode and exitng from this form I need the information contained in a field called newCode to be transferred over to a field called Code in the second form networkRefurbishment.

networkRefurbishment is still open after addASpecialCode is closed, addASpecialCode justs pops up while entering a record in networkRefurbishment.
I use a button to exit from the first form and I have tried the following code in the sub procedure for this button but no luck!

[Forms]![networkRefurbishment]!
Code:
 = [Forms]![addASpecialCode]![newCode] 

Can someone please help me?

Liam
 
Try:
Forms.networkRefurbishment.Code = me.newCode
docmd.close
 
Thanks for the help and I am getting there but now I have another problem. I get the following error :


Run-time error '438':

Object doesn't support this property or method


Any ideas, to be honest I'm lost:-)

Liam
 
What version of Access are you running?
 
Actually...let's try this:

Dim cd as Variant

cd = me.newcode
Forms.networkRefurbishment.Code.setfocus
Forms.networkRefurbishment.Code.text = cd

then insert the docmd.close
 
Actually there's a twist in the tail of this one and I feel like an idiot for not mentioning it sooner. I thought it didn't matter but it's probably why I can't get this to work. The second form networkRefuurbishment is actually a subform on a main form. I thought that this wouldn't matter if I referred to the subform directly.

Would this be the problem? I'm running Access 2000.

Thanks for your help,

an idiot:-)
 
It shouldn't matter. Did you try the additional code i sent you?

And no one is ever an idiot when it comes to Access, just a knowledge sponge that hasn't wiped down the water droplets of new horizons.

WOW...I can't believe i made that up!
 
Hi,

I'm a newbie here. I did a search and this thread is the closest thing that addresses mycurrent problem.

Having followed the thread, I see that the expert is telling the visitor to enter certain code.

Please someone tell me how I can enter that code to work together with my current button code, and not generate any 438 errors, AND update the Service record, as is on my other subform. The other subform has UniqueId as PK. The Service subform which has the button has the "many" UniqueID.
But, the Subform Service also has a Prim. Key of ServiceTicket, BUT it's not linked to any other table.

When a problem actually arises is in two different places:
1) is when I first open my main form. That's when I get the "438
Object invalid . . . . " error.
2) Is when I actually try to update the Service form. You see, it lets me create a new service Ticket number, but not update the record. So it gives me: You can't add or change a record because a related record is required in CustomerEquipment.
And what it's looking at of course is the mismatch between
Subform CustomerEquip and Subform Service: Namely the field
UniqueI, which is not being updated on Servie.

Anyway, here is the code from my button which creates a
new service ticket in Subform Service:

Private Sub cmd30_Click()
Me.Refresh
DoCmd.GoToRecord , , acNewRec

If IsNull(Me.ServiceTicket) = False Then
Beep
If MsgBox("New Service Ticket ? ", _
vbCritical + vbOKCancel) <> vbOK Then
Exit Sub
End If
End If

' get next number

Me.ServiceTicket = Nz(DMax("ServiceTicket", "Service"), 0) + 1
Me.Todays_Date = Date
End Sub


AND, on Mouse Move I have the following:

Private Sub cmd30_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo Err_cmd_Click

'Check control
If Forms!CustomerData.CustomerNumber = 0 Then
Forms!CustomerData.CustomerNumber.SetFocus
MsgBox "NO Don't try to open a new service ticket without entering at least a customer number Click OK on this Message box and the blinking cursor will be at the field so you can enter a customer number"
End If

Exit_cmd_Click:
Exit Sub

Err_cmd_Click:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "cmd_Click"
Resume Exit_cmd_Click

End Sub


Thanks for taking a look,

Jim
 
1) The error is saying that an object variable somewhere is not "set", i.e. it does not point to a valid object and it's value is "Nothing".

2) There are required joins between tables that are expecting a related record in CustomerEquip. For example you can't enter HAMMER as an item on the Service Record if no HAMMER record exists in CustomerEquip

Can you post a zipped copy of the database so that we can view it? There seems to be a number of possible issues that might need to be looked into.
 
Thanks for you instant reply.

I suppose that would be the best way to do it, but I will first have to hack off information from the database that I don't wish shared, as you can understand. And I will need a few minutes to enter some dummy data.

Finally, I need to see if it does the same exact thing as it is doing with my "real" database.

Thanks for taking a look. I'll be back shortly,
Jim
 
Hello again.
I'm back with my database.

I have hacked out the portions I didnt want to disclose, and then verified that it gave me the same exact errors, at the same exact events.

Please see the zipped atchmtn. and know that the first thing that should happen is the form CustomerData should open up which works on my computer.

This is an Access 97 database.

Thanks for taking a look,
Jim
 

Attachments

Jim:
Can you send a PM to me with your e-mail. I have some questions and didn't want to keep posting to the thread.
 

Users who are viewing this thread

Back
Top Bottom