Form OnCurrent code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I moved all my code from the lost focus on the text boxes of my form to the
OnCurrent property of the form. I did this because it has become necessary
because of the amount of data that is being entered.

This is a code that I have to check the totals of some items:

IngTot = Me.QtySRej + Me.QtySLgMed + Me.QtySJumbo + Me.QtySColossal
If IngTot <> 10 And DateAdded > Now() - 1 Then
If MsgBox("Total is not equal to 10. " & "The total equals " &
CStr(IngTot) & ".", vbOKCancel) = vbCancel Then
MsgBox ("Check your entries and correct.")
Me!QtySRej.SetFocus
Else
Me.TotalBulbs = IngTot
End If
Else
Me.TotalBulbs = QtySRej + QtySLgMed + QtySJumbo + QtySColossal
End If

It is not working as I want it to do.

I want it to check every line of new data that is greater than yesterday. It
does all the calculations an DLookUp fields but it does not do my total check
and let me know if the total is <> 10.

I would appreciate any help that I can get with this.

Thanks,
Curt
 
OnCurrent runs whenever the cursor moves to a new record, wther you change
stuff or not. I think you might want to try the form's BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you cancel the
Insert/Update.

HTH,
Barry
 
I want to run the following code when the form opens and the dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client Name.
ClientCode = DLookup("ClientCode", "tblClients", "CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt
 
This looks like a different issue from the earlier one. Is that resolved?

I'm not sure I understand what you're looking for here. The code you posted
looks reasonable. Is it not working as expected? Are you getting errors?

Barry

Curt Hand said:
I want to run the following code when the form opens and the dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client Name.
ClientCode = DLookup("ClientCode", "tblClients", "CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt

Barry Gilbert said:
OnCurrent runs whenever the cursor moves to a new record, wther you change
stuff or not. I think you might want to try the form's BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you cancel the
Insert/Update.

HTH,
Barry
 
This is a new problem but it is part of the whole set of code including the
original I sent. If I put it on the form open event it gives me an error on
all my lookup fields.
I have DLookUp, calculations, if else in the whole code.

Curt

Barry Gilbert said:
This looks like a different issue from the earlier one. Is that resolved?

I'm not sure I understand what you're looking for here. The code you posted
looks reasonable. Is it not working as expected? Are you getting errors?

Barry

Curt Hand said:
I want to run the following code when the form opens and the dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client Name.
ClientCode = DLookup("ClientCode", "tblClients", "CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt

Barry Gilbert said:
OnCurrent runs whenever the cursor moves to a new record, wther you change
stuff or not. I think you might want to try the form's BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you cancel the
Insert/Update.

HTH,
Barry

:

I moved all my code from the lost focus on the text boxes of my form to the
OnCurrent property of the form. I did this because it has become necessary
because of the amount of data that is being entered.

This is a code that I have to check the totals of some items:

IngTot = Me.QtySRej + Me.QtySLgMed + Me.QtySJumbo + Me.QtySColossal
If IngTot <> 10 And DateAdded > Now() - 1 Then
If MsgBox("Total is not equal to 10. " & "The total equals " &
CStr(IngTot) & ".", vbOKCancel) = vbCancel Then
MsgBox ("Check your entries and correct.")
Me!QtySRej.SetFocus
Else
Me.TotalBulbs = IngTot
End If
Else
Me.TotalBulbs = QtySRej + QtySLgMed + QtySJumbo + QtySColossal
End If

It is not working as I want it to do.

I want it to check every line of new data that is greater than yesterday. It
does all the calculations an DLookUp fields but it does not do my total check
and let me know if the total is <> 10.

I would appreciate any help that I can get with this.

Thanks,
Curt
 
It might work if you put it in the OnLoad event.

Barry

Curt Hand said:
This is a new problem but it is part of the whole set of code including the
original I sent. If I put it on the form open event it gives me an error on
all my lookup fields.
I have DLookUp, calculations, if else in the whole code.

Curt

Barry Gilbert said:
This looks like a different issue from the earlier one. Is that resolved?

I'm not sure I understand what you're looking for here. The code you posted
looks reasonable. Is it not working as expected? Are you getting errors?

Barry

Curt Hand said:
I want to run the following code when the form opens and the dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client Name.
ClientCode = DLookup("ClientCode", "tblClients", "CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt

:

OnCurrent runs whenever the cursor moves to a new record, wther you change
stuff or not. I think you might want to try the form's BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you cancel the
Insert/Update.

HTH,
Barry

:

I moved all my code from the lost focus on the text boxes of my form to the
OnCurrent property of the form. I did this because it has become necessary
because of the amount of data that is being entered.

This is a code that I have to check the totals of some items:

IngTot = Me.QtySRej + Me.QtySLgMed + Me.QtySJumbo + Me.QtySColossal
If IngTot <> 10 And DateAdded > Now() - 1 Then
If MsgBox("Total is not equal to 10. " & "The total equals " &
CStr(IngTot) & ".", vbOKCancel) = vbCancel Then
MsgBox ("Check your entries and correct.")
Me!QtySRej.SetFocus
Else
Me.TotalBulbs = IngTot
End If
Else
Me.TotalBulbs = QtySRej + QtySLgMed + QtySJumbo + QtySColossal
End If

It is not working as I want it to do.

I want it to check every line of new data that is greater than yesterday. It
does all the calculations an DLookUp fields but it does not do my total check
and let me know if the total is <> 10.

I would appreciate any help that I can get with this.

Thanks,
Curt
 
It doesn't run any of the code on the OnLoad event and I have tried several
other events and it will not update the form and perform the calculations.

Using the OnOpen event this is the error I get
Run-time error '-2147352567(800200009):
You can't assign a value to this object.

Thanks for being patient with me.
Curt

Barry Gilbert said:
It might work if you put it in the OnLoad event.

Barry

Curt Hand said:
This is a new problem but it is part of the whole set of code including the
original I sent. If I put it on the form open event it gives me an error on
all my lookup fields.
I have DLookUp, calculations, if else in the whole code.

Curt

Barry Gilbert said:
This looks like a different issue from the earlier one. Is that resolved?

I'm not sure I understand what you're looking for here. The code you posted
looks reasonable. Is it not working as expected? Are you getting errors?

Barry

:

I want to run the following code when the form opens and the dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client Name.
ClientCode = DLookup("ClientCode", "tblClients", "CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt

:

OnCurrent runs whenever the cursor moves to a new record, wther you change
stuff or not. I think you might want to try the form's BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you cancel the
Insert/Update.

HTH,
Barry

:

I moved all my code from the lost focus on the text boxes of my form to the
OnCurrent property of the form. I did this because it has become necessary
because of the amount of data that is being entered.

This is a code that I have to check the totals of some items:

IngTot = Me.QtySRej + Me.QtySLgMed + Me.QtySJumbo + Me.QtySColossal
If IngTot <> 10 And DateAdded > Now() - 1 Then
If MsgBox("Total is not equal to 10. " & "The total equals " &
CStr(IngTot) & ".", vbOKCancel) = vbCancel Then
MsgBox ("Check your entries and correct.")
Me!QtySRej.SetFocus
Else
Me.TotalBulbs = IngTot
End If
Else
Me.TotalBulbs = QtySRej + QtySLgMed + QtySJumbo + QtySColossal
End If

It is not working as I want it to do.

I want it to check every line of new data that is greater than yesterday. It
does all the calculations an DLookUp fields but it does not do my total check
and let me know if the total is <> 10.

I would appreciate any help that I can get with this.

Thanks,
Curt
 
What is the "ClientCode" in your code? Is it a textbox, a field? If you're
trying to set the default value for a textbox, you could put the DLookup
statements in the Default property of your textboxes.

Barry

Curt Hand said:
It doesn't run any of the code on the OnLoad event and I have tried several
other events and it will not update the form and perform the calculations.

Using the OnOpen event this is the error I get
Run-time error '-2147352567(800200009):
You can't assign a value to this object.

Thanks for being patient with me.
Curt

Barry Gilbert said:
It might work if you put it in the OnLoad event.

Barry

Curt Hand said:
This is a new problem but it is part of the whole set of code including the
original I sent. If I put it on the form open event it gives me an error on
all my lookup fields.
I have DLookUp, calculations, if else in the whole code.

Curt

:

This looks like a different issue from the earlier one. Is that resolved?

I'm not sure I understand what you're looking for here. The code you posted
looks reasonable. Is it not working as expected? Are you getting errors?

Barry

:

I want to run the following code when the form opens and the dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client Name.
ClientCode = DLookup("ClientCode", "tblClients", "CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt

:

OnCurrent runs whenever the cursor moves to a new record, wther you change
stuff or not. I think you might want to try the form's BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you cancel the
Insert/Update.

HTH,
Barry

:

I moved all my code from the lost focus on the text boxes of my form to the
OnCurrent property of the form. I did this because it has become necessary
because of the amount of data that is being entered.

This is a code that I have to check the totals of some items:

IngTot = Me.QtySRej + Me.QtySLgMed + Me.QtySJumbo + Me.QtySColossal
If IngTot <> 10 And DateAdded > Now() - 1 Then
If MsgBox("Total is not equal to 10. " & "The total equals " &
CStr(IngTot) & ".", vbOKCancel) = vbCancel Then
MsgBox ("Check your entries and correct.")
Me!QtySRej.SetFocus
Else
Me.TotalBulbs = IngTot
End If
Else
Me.TotalBulbs = QtySRej + QtySLgMed + QtySJumbo + QtySColossal
End If

It is not working as I want it to do.

I want it to check every line of new data that is greater than yesterday. It
does all the calculations an DLookUp fields but it does not do my total check
and let me know if the total is <> 10.

I would appreciate any help that I can get with this.

Thanks,
Curt
 
I am having problems running a piece of code when the form loads. It needs to
run after the form has been loaded and the textboxes have been updated by the
dataset. This code simply updates another textbox with some information.
Everything should run fine, but I'm having problems identifying exactly which
Event this code needs to be place inside.



Curt Hand said:
It doesn't run any of the code on the OnLoad event and I have tried several
other events and it will not update the form and perform the calculations.

Using the OnOpen event this is the error I get
Run-time error '-2147352567(800200009):
You can't assign a value to this object.

Thanks for being patient with me.
Curt

Barry Gilbert said:
It might work if you put it in the OnLoad event.

Barry

Curt Hand said:
This is a new problem but it is part of the whole set of code including the
original I sent. If I put it on the form open event it gives me an error on
all my lookup fields.
I have DLookUp, calculations, if else in the whole code.

Curt

:

This looks like a different issue from the earlier one. Is that resolved?

I'm not sure I understand what you're looking for here. The code you posted
looks reasonable. Is it not working as expected? Are you getting errors?

Barry

:

I want to run the following code when the form opens and the dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client Name.
ClientCode = DLookup("ClientCode", "tblClients", "CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt

:

OnCurrent runs whenever the cursor moves to a new record, wther you change
stuff or not. I think you might want to try the form's BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you cancel the
Insert/Update.

HTH,
Barry

:

I moved all my code from the lost focus on the text boxes of my form to the
OnCurrent property of the form. I did this because it has become necessary
because of the amount of data that is being entered.

This is a code that I have to check the totals of some items:

IngTot = Me.QtySRej + Me.QtySLgMed + Me.QtySJumbo + Me.QtySColossal
If IngTot <> 10 And DateAdded > Now() - 1 Then
If MsgBox("Total is not equal to 10. " & "The total equals " &
CStr(IngTot) & ".", vbOKCancel) = vbCancel Then
MsgBox ("Check your entries and correct.")
Me!QtySRej.SetFocus
Else
Me.TotalBulbs = IngTot
End If
Else
Me.TotalBulbs = QtySRej + QtySLgMed + QtySJumbo + QtySColossal
End If

It is not working as I want it to do.

I want it to check every line of new data that is greater than yesterday. It
does all the calculations an DLookUp fields but it does not do my total check
and let me know if the total is <> 10.

I would appreciate any help that I can get with this.

Thanks,
Curt
 
Do you have controls and fields with the same name (ClientName, for
instance)? I don't know if that is the problem here, but it's often worth
checking.

Curt Hand said:
I am having problems running a piece of code when the form loads. It needs
to
run after the form has been loaded and the textboxes have been updated by
the
dataset. This code simply updates another textbox with some information.
Everything should run fine, but I'm having problems identifying exactly
which
Event this code needs to be place inside.



Curt Hand said:
It doesn't run any of the code on the OnLoad event and I have tried
several
other events and it will not update the form and perform the
calculations.

Using the OnOpen event this is the error I get
Run-time error '-2147352567(800200009):
You can't assign a value to this object.

Thanks for being patient with me.
Curt

Barry Gilbert said:
It might work if you put it in the OnLoad event.

Barry

:

This is a new problem but it is part of the whole set of code
including the
original I sent. If I put it on the form open event it gives me an
error on
all my lookup fields.
I have DLookUp, calculations, if else in the whole code.

Curt

:

This looks like a different issue from the earlier one. Is that
resolved?

I'm not sure I understand what you're looking for here. The code
you posted
looks reasonable. Is it not working as expected? Are you getting
errors?

Barry

:

I want to run the following code when the form opens and the
dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client
Name.
ClientCode = DLookup("ClientCode", "tblClients",
"CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients",
"CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt

:

OnCurrent runs whenever the cursor moves to a new record, wther
you change
stuff or not. I think you might want to try the form's
BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you
cancel the
Insert/Update.

HTH,
Barry

:

I moved all my code from the lost focus on the text boxes of
my form to the
OnCurrent property of the form. I did this because it has
become necessary
because of the amount of data that is being entered.

This is a code that I have to check the totals of some items:

IngTot = Me.QtySRej + Me.QtySLgMed + Me.QtySJumbo +
Me.QtySColossal
If IngTot <> 10 And DateAdded > Now() - 1 Then
If MsgBox("Total is not equal to 10. " & "The total
equals " &
CStr(IngTot) & ".", vbOKCancel) = vbCancel Then
MsgBox ("Check your entries and correct.")
Me!QtySRej.SetFocus
Else
Me.TotalBulbs = IngTot
End If
Else
Me.TotalBulbs = QtySRej + QtySLgMed + QtySJumbo +
QtySColossal
End If

It is not working as I want it to do.

I want it to check every line of new data that is greater
than yesterday. It
does all the calculations an DLookUp fields but it does not
do my total check
and let me know if the total is <> 10.

I would appreciate any help that I can get with this.

Thanks,
Curt
 
Curt,

don't know that it matters, but on the line "IngTot = ..." you're
referencing controls, and on the line "Me.TotalBulbs = ..." you're
referencing variables. I'm only seeing a snippet of your code, so ...

Is TotalBulbs a bound control?

Brian
 
Thanks everyone for all your help.

Curt

Curt Hand said:
I am having problems running a piece of code when the form loads. It needs to
run after the form has been loaded and the textboxes have been updated by the
dataset. This code simply updates another textbox with some information.
Everything should run fine, but I'm having problems identifying exactly which
Event this code needs to be place inside.



Curt Hand said:
It doesn't run any of the code on the OnLoad event and I have tried several
other events and it will not update the form and perform the calculations.

Using the OnOpen event this is the error I get
Run-time error '-2147352567(800200009):
You can't assign a value to this object.

Thanks for being patient with me.
Curt

Barry Gilbert said:
It might work if you put it in the OnLoad event.

Barry

:

This is a new problem but it is part of the whole set of code including the
original I sent. If I put it on the form open event it gives me an error on
all my lookup fields.
I have DLookUp, calculations, if else in the whole code.

Curt

:

This looks like a different issue from the earlier one. Is that resolved?

I'm not sure I understand what you're looking for here. The code you posted
looks reasonable. Is it not working as expected? Are you getting errors?

Barry

:

I want to run the following code when the form opens and the dataset has been
loaded into the text boxes.
'This is to look up and insert the correct Client Code and Client Name.
ClientCode = DLookup("ClientCode", "tblClients", "CustomerNumber=" &
[CustomerNumber])
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber])
Your help will be greatly appreciated.

Curt

:

OnCurrent runs whenever the cursor moves to a new record, wther you change
stuff or not. I think you might want to try the form's BeforeUpdate or
BeforeInsert events. These offer the advantage of letting you cancel the
Insert/Update.

HTH,
Barry

:

I moved all my code from the lost focus on the text boxes of my form to the
OnCurrent property of the form. I did this because it has become necessary
because of the amount of data that is being entered.

This is a code that I have to check the totals of some items:

IngTot = Me.QtySRej + Me.QtySLgMed + Me.QtySJumbo + Me.QtySColossal
If IngTot <> 10 And DateAdded > Now() - 1 Then
If MsgBox("Total is not equal to 10. " & "The total equals " &
CStr(IngTot) & ".", vbOKCancel) = vbCancel Then
MsgBox ("Check your entries and correct.")
Me!QtySRej.SetFocus
Else
Me.TotalBulbs = IngTot
End If
Else
Me.TotalBulbs = QtySRej + QtySLgMed + QtySJumbo + QtySColossal
End If

It is not working as I want it to do.

I want it to check every line of new data that is greater than yesterday. It
does all the calculations an DLookUp fields but it does not do my total check
and let me know if the total is <> 10.

I would appreciate any help that I can get with this.

Thanks,
Curt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top