Hi guys,
I am trying to get a value from a textbox on a form to use in another, seperate form, i have tried -
Dim username As String
-
-
Forms!frmLogin!txtMembername = Me.Text1
-
username = Text1
-
MsgBox "" & username
-
(I made a textbox called text1 and made it invisible because I kept haveing errors assigning the value to a variable eg. UserName, but it didn't work, but thats why it is in there!)
I have looked at the other threads on this subject, but I can't understand why I keep getting errors (that code give me an invalid use of null error even when the other form is open and txtMemberName has text in it. Although, every time i run this it wipes the field in the other form too...which is annoying)
Cheers for any responces!
Mark
14 33010
Hi guys,
I am trying to get a value from a textbox on a form to use in another, seperate form, i have tried -
Dim username As String
-
-
Forms!frmLogin!txtMembername = Me.Text1
-
username = Text1
-
MsgBox "" & username
-
(I made a textbox called text1 and made it invisible because I kept haveing errors assigning the value to a variable eg. UserName, but it didn't work, but thats why it is in there!)
I have looked at the other threads on this subject, but I can't understand why I keep getting errors (that code give me an invalid use of null error even when the other form is open and txtMemberName has text in it. Although, every time i run this it wipes the field in the other form too...which is annoying)
Cheers for any responces!
Mark
Hi Mark,
I am going to assume that 'the other form' is Forms!frmLogin and your code above is the current form: - Me.Text1.Text = Forms!frmLogin!txtMembername.Text
-
username = Me.Text1.Text
-
MsgBox username
Of course I don't know if your intention with the message box is simply debugging, otherwise you would just write: - MsgBox Forms!frmLogin!txtMembername.Text
Hi Mark,
I am going to assume that 'the other form' is Forms!frmLogin and your code above is the current form: - Me.Text1.Text = Forms!frmLogin!txtMembername.Text
-
username = Me.Text1.Text
-
MsgBox username
Of course I don't know if your intention with the message box is simply debugging, otherwise you would just write: - MsgBox Forms!frmLogin!txtMembername.Text
Hi, Sorry yeah it was just there for debugging!
I get this error now, I can't figure out why though,
"Run time error '2185'
You can't reference a property or method for a control unless the controll has a focus"
If you figure it out could you explain it a bit me?
Cheers
Mark
Is frmLogin open when you try to run this code?
Is frmLogin open when you try to run this code?
Yeah I have it open and have a value in the txtMemberName field too. Weird, you can get the DB from http://www.cmdclan.co.uk/Temp/jr_system.mdb if you want an actual look at it, the test form I am using is just the form1 form, and the one I am reading from is the frmLogin
Cheers
Mark
NeoPa 32,498
Expert Mod 16PB
Mark,
I tried the version below and it worked fine.
I lost the .Text bits and added in the Nz() as an empty name would have caused the code to crash. - Private Sub Command3_Click()
-
Dim username As String
-
-
Me.Text1 = Forms!frmLogin!txtMembername
-
username = Nz(Me.Text1, "")
-
MsgBox username
-
-
End Sub
Mark,
I tried the version below and it worked fine.
I lost the .Text bits and added in the Nz() as an empty name would have caused the code to crash. - Private Sub Command3_Click()
-
Dim username As String
-
-
Me.Text1 = Forms!frmLogin!txtMembername
-
username = Nz(Me.Text1, "")
-
MsgBox username
-
-
End Sub
Hi
I still couldn't get that to work, so the button on form1 now does -
Private Sub Command3_Click()
-
Dim username As String
-
-
username = Nz(Forms!frmLogin!txtMembername, "")
-
MsgBox username
-
End Sub
-
And that seems to work fine! haha,
I changed the function of Login to point to that form1 form, but that is just for the purposes of debugging,
thanks for all your help!
Mark
NeoPa 32,498
Expert Mod 16PB
I've no idea why you couldn't get it to work but I suppose that now it's working that's no longer a problem ;)
I've no idea why you couldn't get it to work but I suppose that now it's working that's no longer a problem ;)
Yeah it's weird the way things just don't work sometimes, especially when one person can get them to work... Ghost in the Machine I guess
Yeah it's weird the way things just don't work sometimes, especially when one person can get them to work... Ghost in the Machine I guess
It might be weird and it is the time when there is most learning taking place if you stick with it. There is no ghost in the machine, just things to learn :)
Hi there,
Lets see if this link helps get rid of the GHOST in your machine, hope it helps. Good luck & Take care. :) Variable Scope
Hi there,
Lets see if this link helps get rid of the GHOST in your machine, hope it helps. Good luck & Take care. :) Variable Scope
Hehe, i like the sound that code made as it wooshed over my head. I looked away as soon as I saw the extention .dll :o)
My system is a throw away prototype that just has to demonstrate an overall functionally, but not BE that functional. If you catch my drift, I'm trying to learn VB8 with SQL Server CE or a mobile app im writing, and it is complicated enough without trying to learn all this razamatazz hehe.
NeoPa 32,498
Expert Mod 16PB
Mark,
I'm sure you didn't mean to sound critical, but please bear in mind that these members are trying to help you and have no way of knowing how appropriate a suggestion is for you personally.
Mark,
I'm sure you didn't mean to sound critical, but please bear in mind that these members are trying to help you and have no way of knowing how appropriate a suggestion is for you personally.
Yeah I wasn't being critical at all! Sorry guys, I really appreciate all your help! Didn't mean to sound arsy. You have saved my bacon in these forums with your advice already, I have the upmost respect for all of you!
Cheers
Mark
NeoPa 32,498
Expert Mod 16PB Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
4 posts
views
Thread by beveled edges |
last post: by
|
1 post
views
Thread by G Kannan |
last post: by
|
11 posts
views
Thread by Ray Muforosky |
last post: by
|
4 posts
views
Thread by gimme_this_gimme_that |
last post: by
|
8 posts
views
Thread by =?Utf-8?B?QW1yaXQgS29obGk=?= |
last post: by
| | | | | | | | | | | | | | | |